首页 > 其他 > 详细

代码笔记-----$this->table('classes')->where('id='.$id)->find();

时间:2015-10-08 18:20:29      阅读:534      评论:0      收藏:0      [点我收藏+]

来自百度知道:http://zhidao.baidu.com/link?url=WA7iaK1GU68M4D1iETM5HCc0tMnjPWhqnoLqPDocCgIt60NUolBB54VUcrykasofJRLTDkXHL0dbtvKeSmfTY_

问:php中有 $this->table(‘classes‘)->where(‘id=‘.$id)->find(); 请问如何理解?

答:

class a{
private $table;
private $where;
public function table($tableName){
$this->table = $tableName;
return $this;
}
public function where($where){
$this->where = $where;
return $this;
}
public function find(){
$sql = "select * from".$this->$table."where ".$this->where;
}
}

}
基本上是这种 其实就是return $this;这会返回当前的类的对象引用 所以你$this->table(‘classes‘)->where()继续执行where方法

代码笔记-----$this->table('classes')->where('id='.$id)->find();

原文:http://www.cnblogs.com/asdfgh/p/4861547.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!