==================================================php
------------------------------------------------------------------------html
public function test()
{
$comment = new Comment();
$comment->object::get($comment->object_id);
}
-----------
if(!request()->isPost()){
}else{
$data = input('post.);
}
session(null, 'user');
// 跳出
return $this->redirect(url('login/index'));sql
===================================thinkphp
// allowField 過濾data數組中非數據表中的數據
return $this->allowField(true)->save($data, ['id'=>$id]);api
<!--包含頭部文件-->
{include file="public/header" /}數組
-------session
<!--包含footer文件-->
{include file="public/footer" /}app
------------------------------------------------------------------------post
輸出控制器:echo request()->controller();fetch
$request = Request::instance();
echo "當前模塊名稱是" . $request->module();
echo "當前控制器名稱是" . $request->controller();
echo "當前操做名稱是" . $request->action();
unset($data['id']) //刪除單個數組中的值
----------------------------------------------------------------------
function isright_format(value,row,index){
return value==1 ? '<span style="color:red;">教學助理</span>' : '<span style="color:#7df;">非助理</span>';
}
---------------------------------------------------------------------
<input type="text" name="captcha" placeholder="請輸入驗證碼" required=""><br>
<img src="<{:captcha_src()}>" width="95" height="45" onclick="this.src='<{:captcha_src()}>'"><br><br>
$captcha = $_REQUEST['captcha'];
if(!captcha_check($captcha)){
//驗證失敗
$this->error('驗證碼輸入錯誤');
}else{
$this->success('成功',url('user/login'));
}
----------------------------------------------------------------------------
$result=$this->validate($data,'Student');
return $this->success('登陸成功');
return $this->error('驗證碼輸入錯誤,請重新輸入');
return $this->fetch('index');
return view();
return redirect("$cc/index/index");
--------------------------------------------------------------------------------------
//循環輸出一級欄目
<{volist name="category" id="vo"}>
<a class="nav-a" href="#" ><li class=""><{$vo.catname}></li></a>
<{/volist}>
<{:url(' admin ')}> ——方法不存在
Route::any('adminapi/v1/login','adminapi/v1.login/index');
【模塊/控制器/方法】
<{:url(' admin / index ')}>
-------------------------------------------------------------------------------------
use app\common\model\Classcourse as Classcourse_Model;
$stu = new Classcourse_Model();
$cnt = $stu->allowField(true)->save($data);
--------------------------------------------------------------------------------
//跳轉頁面
onclick="loadtea()"
function loadtea(){
url="<{:url('all')}>";
}
-----------------------------------------------------------------------
public function index()
{
// 模板變量賦值
$this->assign('name','ThinkPHP');
$this->assign('email','thinkphp@qq.com');
// 或者批量賦值
$this->assign([
'name' => 'ThinkPHP',
'email' => 'thinkphp@qq.com'
]);
// 模板輸出
return $this->fetch('index');
}
============================================================================================
安裝:
//訪問模型
http://localhost/tp5/public/index.php/admin
-------------------------------------------------------------------------------------------------------------------
__STATIC__:/tp5/static
$_REQUEST
-------------------------------------------------------------------------------------------------------------------
路徑:application/config.php
// 視圖輸出字符串內容替換
'view_replace_str' => ['__EASYUI__'=>'/tp_scoring/public/static',
'__EXTEND__'=>'/tp_scoring/extend',
'__IMG__'=>'/tp_scoring/public/static/img'
],
//加載與方法同名的頁面
return $this->fetch();
// return view();
============================= 分頁
$status = $_GET['status'];
$list = db('user')->where('user_type',$status)->order('id desc')->
paginate(10,false,['query'=>array('status'=>$status)]);
----------------------------------------
-----------------------
//帳戶記錄
$where = 'sign=1';
if (input('get.keywords')) {
$keywords = input('get.keywords');
$str = ' user_name like "%' . input("get.keywords") . '%" or id="'.$keywords.'"';
$user_id = db('user')->where($str)->value('id');
if($user_id){
$where .= ' and user_id ='. $user_id;
}
}
user_name like "%
if (input('get.start')) {
$starttime = strtotime(input('get.start'));
$where .= ' and add_time >= "' . $starttime . '"';
}
if (input('get.end')) {
$endtime = strtotime(input('get.end')) + 86400;
$where .= ' and add_time <= "' . $endtime . '"';
}
$list = db('prize_log')->order('id desc')->where($where)->paginate(10);
$this->assign('page', $list->render());//先將page賦值出來
$list = db('prize_log')->order('id desc')->where(sign=1 and add_time <= "' . $endtime)->paginate(10);
-----------------------------------------------------------------------------
// 定義demo模塊的自動生成 (按照實際定義的文件名生成)
'demo' => [
'__file__' => ['common.php'],
'__dir__' => ['behavior', 'controller', 'model', 'view'],
'controller' => ['Index', 'Test', 'UserType'],
'model' => ['User', 'UserType'],
'view' => ['index/index'],
],
// 定義admin模塊的自動生成 (本身定義的admin)
'admin' => [
'__file__' => ['common.php'],
'__dir__' => [ 'controller', 'validate', 'view'],
'controller' => ['Base', 'Index', 'Test'],
'validate' => ['User', 'Category'],
'view' => ['Index/index','Public/header','Public/footer'],
],
// 定義common模塊的自動生成 (本身定義的common)
'common' => [
'__file__' => ['common.php'],
'__dir__' => [ 'controller', 'model', 'validate'],
'controller' => [ 'Index'],
'model' => ['Admin','User', 'Category'],
'validate' => ['Bis'],
],
-------------------------------------------------------------------------------------
Base.php
<?php
namespace app\index\controller;
use think\Controller;
class Base extends Controller
-------------------------------------------------
user.php
<?php
namespace app\index\controller;
use think\Controller;
class User extends Controller
====================================模型調用
<?php
namespace app\index\controller;
use think\Controller;
class User extends Controller
{
try {
$res = model('User')->add($data);
}catch (\Exception $e) {
$this->error($e->getMessage());
}
-----------
<?php
namespace app\common\model;
use think\Model;
class User extends BaseModel
{
public function add($data = []) {
// 若是提交的數據不是數組
if(!is_array($data)) {
exception('傳遞的數據不是數組');
}
$data['status'] = 1;
return $this->data($data)->allowField(true)
->save();
}
/**
* 根據用戶名獲取用戶信息
* @param $username
*/
public function getUserByUsername($username) {
if(!$username) {
exception('用戶名不合法');
}
$data = ['username' => $username];
return $this->where($data)->find();
}
}
=======================================================================
$data = input('post.');
//dump($data);exit;
//halt($data);
//echo 12;exit;
//$data['status'] = 10;
debug('begin');
echo debug('begin','end')
$validate = validate('Category');
$data['name'] = htmlentities($data['name']);
$subsql = Db::table('think_work') ->where('status',1) ->field('artist_id,count(id) count') ->group('artist_id') ->buildSql(); Db::table('think_user') ->alias('a') ->join([$subsql=> 'w'], 'a.artist_id = w.artist_id') ->select();