find函数的原型
复制代码 代码如下:
function & find($conditions, $sort = null, $fields = '*', $querylinks = true)
{
$rowset =& $this->findAll($conditions, $sort, 1, $fields, $querylinks);
if (is_array($rowset)) {
$row = reset($rowset);
} else {
$row = false;
}
unset($rowset);
return $row;
}
find同findAll的区别在于find少了一个参数$limit,也就是说,find只会找出符合条件的第一条记录
$conditions,
$sort = null,
$fields = ‘*'
$querylinks = true
$conditions = null, 查询条件
通常数组,包含字段名和值
例如
复制代码 代码如下:
array('fieldname' => 'value1','fieldnameb' => 'value2')
$sort = null, 排序
字段以及排序的方式,通常这是一个字串
例如
复制代码 代码如下:
'ID ASC,post_date DESC' //如果只有一个条件可以这样 'ID ASC'
$fields = ‘*';, 需要查询显示的字段,默认全部显示
例如
复制代码 代码如下:
array('ID','post_title','post_parent')
$querylinks = true
fleaphp函数find方法的使用和示例
复制代码 代码如下:
$rowsets = $tableposts->find(array('post_type'=>'post'),'ID ASC,post_date DESC',array('ID','post_title','post_parent'));
dump($rowsets);



