fleaphp crud操作之find函數的使用方法_PHP教程

來源:互聯網
上載者:User
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...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.