Home > Backend Development > PHP Tutorial > fleaphp fleaphp crud operation method of using find function

fleaphp fleaphp crud operation method of using find function

WBOY
Release: 2016-07-29 08:44:54
Original
1064 people have browsed it

The prototype of the find function

Copy the 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 the first record that meets the conditions
$conditions,
$sort = null,
$fields = '*'
$queryLinks = true
$conditions = null, query conditions
usually an array, containing field names and values ​​
for example

Copy the code The code is as follows:


array('fieldname' => 'value1','fieldnameb' => 'value2')


$sort = null, sort the
fields and how to sort , usually this is a string
For example

Copy code The code is as follows:


'ID ASC,post_date DESC' //If there is only one condition, this can be 'ID ASC'


$fields = '* ';, the fields that need to be queried and displayed are displayed by default
For example

Copy the 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);

The above introduces how to use the find function of fleaphp fleaphp crud operation, including the content of fleaphp. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template