find函數的原型
複製代碼 代碼如下:
/**
* 返回合格第一條記錄及所有關聯的資料,查詢沒有結果返回 false
*
* @param mixed $conditions
* @param string $sort
* @param mixed $fields
* @param mixed $queryLinks
*
* @return array
*/
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);
http://www.bkjia.com/PHPjc/323263.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/323263.htmlTechArticlefind函數的原型 複製代碼 代碼如下: /** * 返回合格第一條記錄及所有關聯的資料,查詢沒有結果返回 false * * @param mixed $conditions * @pa...