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 be queried Displayed field name
Usage example of findByField function in fleaphp crud operation
Copy 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 to the database
$dsn = array(
'driver' => 'mysql',
'host' => 'localhost',
'login' => 'root',
'password' => '' ,
'database' => 'wordpress'
);
FLEA::setAppInf('dbDSN',$dsn);
//Read 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);
http://www.bkjia.com/PHPjc/323264.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323264.htmlTechArticlefindByField function prototype copy code code is as follows: /** * Returns the first record with the specified field value* * @param string $field * @param mixed $value * @param string $sort * @param...