Prototype of find function
Copy code The code is as follows:
/**
* Returns the first record that meets the conditions and all associated data. If the query has no result, it returns 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;
}
The difference between find and findAll is that find lacks one parameter $limit, that is to say, find will only find those that meet the conditions The first record of
$conditions,
$sort = null,
$fields = '*'
$queryLinks = true
$conditions = null, query conditions
usually array , including field name and value
For example
Copy code The code is as follows:
array('fieldname' => ' value1','fieldnameb' => 'value2')
$sort = null, sort the
field and the sorting method, usually this is a string
such as
Copy code The code is as follows:
'ID ASC,post_date DESC' //If there is only one condition, this can be done like this 'ID ASC'
$fields = '*';, the fields that need to be queried are displayed by default.
For example,
Copy code The code is as follows :
array('ID','post_title','post_parent')
$queryLinks = true
Usage and examples of fleaphp function find method
Copy code The code is as follows:
$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.htmlTechArticleThe prototype copy code of the find function is as follows: /** * Returns the first record that meets the conditions and all associations The data, the query returns false * * @param mixed $conditions * @pa...