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

fleaphp fleaphp crud operation method of using findByField function

WBOY
Release: 2016-07-29 08:44:59
Original
1012 people have browsed it

findByField function prototype

Copy code The code is as follows:


/**
* Returns the first record with the specified field value
*
* @param string $field
* @param mixed $value
* @param string $sort
* @param mixed $fields
*
* @return array
*/
function & findByField($field, $value, $sort = null, $fields = '*')
{
return $this->find(array($field => $value), $sort, $fields);
}


findByField function parameter description
$field provides the queried field
$value provides the queried value
$sort sorting method
$fields needs to query the displayed field name
fleaphp crud operation usage example of findByField function

Copy the code The code is as follows:


$dirname = dirname(__FILE__);
define(' APP_DIR', $dirname . '/APP');
define('NO_LEGACY_FLEAPHP', true);
require($dirname.'/FleaPHP/FLEA/FLEA.php');
//Set the cache directory
FLEA:: setAppInf('internalCacheDir',$dirname.'/_Cache');
//Link database
$dsn = array(
'driver' => 'mysql',
'host' => 'localhost',
' login' => 'root',
'password' => '',
'database' => 'wordpress'
);
FLEA::setAppInf('dbDSN',$dsn);
//Read Get the content of wp_posts
FLEA::loadClass('FLEA_Db_TableDataGateway');
class Teble_Class extends FLEA_Db_TableDataGateway {
var $tableName = 'wp_posts';
var $primaryKey = 'ID';
}
$tableposts =& new Teble_Class() ;
$rowsets = $tableposts->findByField('ID',4,'post_date DESC',array('ID','post_title'));
dump($rowsets);

The above introduces how to use the findByField function of fleaphp fleaphp crud operation, including fleaphp content. 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