==================================================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();