本文整理汇总了PHP中Phalcon\Mvc\Model::findFirst方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::findFirst方法的具体用法?PHP Model::findFirst怎么用?PHP Model::findFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\Model
的用法示例。
在下文中一共展示了Model::findFirst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findFirst
public static function findFirst($parameters = NULL, $hostType = NULL)
{
$class = get_called_class();
$object = new $class();
BaseModel::$tableName = $object->getSource();
BaseModel::$hostType = $hostType;
return parent::findFirst($parameters);
}
示例2: findFirst
/**
* Caches models data in memory
*
* @param mixed $parameters
* @return $this
*/
public static function findFirst($parameters = null)
{
// Create an unique key based on the parameters
if ($key = self::createKey($parameters)) {
$parameters['cache'] = ['key' => $key];
}
return parent::findFirst($parameters);
}
示例3: findFirstAsArray
public static function findFirstAsArray($id, $pullDocuments = false)
{
$p = parent::findFirst($id);
$p = $p->toArray();
if ($pullDocuments) {
$p['documents'] = Documents::findByProjectId($id);
}
return $p;
}
示例4: findFirst
public static function findFirst($parameters = null)
{
if (!is_array($parameters) || !array_key_exists('cache', $parameters)) {
if (is_array($parameters)) {
$parameters['cache'] = array("key" => self::_createKey($parameters), "lifetime" => 3600);
} else {
$parameters = [$parameters, 'cache' => ["key" => self::_createKey($parameters), "lifetime" => 3600]];
}
}
return parent::findFirst($parameters);
}
示例5: findFirstOrFail
/**
* FindFirst that throws an ResourceNotFoundException.
*
* @param null $parameters
* @param string $resource_id
* @return Model
* @throws ResourceNotFoundException
*/
public static function findFirstOrFail($parameters = null, $resource_id = null)
{
$result = parent::findFirst($parameters);
if ($resource_id == null) {
$full_path = explode('\\', get_called_class());
$resource_id = end($full_path);
}
if (empty($result)) {
throw new ResourceNotFoundException($resource_id . ' Not Found');
} else {
return $result;
}
}
示例6: findFirst
/**
* Caches models data in memory
*
* @param null $parameters
*
* @return Model
*/
public static function findFirst($parameters = null)
{
$key = null;
if (isset($parameters[0]) && isset($parameters['bind'])) {
$key = $parameters[0] . '-' . join('-', $parameters['bind']);
} else {
if (isset($parameters['conditions']) && isset($parameters['bind'])) {
$key = $parameters['conditions'] . '-' . join('-', $parameters['bind']);
}
}
if ($key) {
$key = preg_replace('/[^0-9A-Za-z]/', '-', get_called_class() . '-' . $key);
$parameters['cache'] = array('key' => $key);
}
return parent::findFirst($parameters);
}
示例7: findFirst
/**
* Allows to query the first record that match the specified conditions
*
* @param mixed $parameters
* @return Questions
*/
public static function findFirst($parameters = null)
{
return parent::findFirst($parameters);
}
示例8: findFirst
/**
* @return User
*/
public static function findFirst($parameters = array())
{
return parent::findFirst($parameters);
}
示例9: findFirst
public static function findFirst($parameters = null)
{
$needFind = array_merge($parameters, self::$needGet);
return parent::findFirst($needFind);
}
示例10: findById
/**
* Finds record by its ID
*
* @param $id
* @return \Phalcon\Mvc\Model\ResultsetInterface
*/
public static function findById($id)
{
return parent::findFirst(array("conditions" => "id = ?1", "bind" => array(1 => $id)));
}
示例11: findFirst
public static function findFirst($parameters = NULL)
{
$result = parent::findFirst($parameters = null);
$_oldTags = $result->tags;
return $result;
}
示例12: findFirst
/**
* Allows to query the first record that match the specified conditions
*
* @param array $parameters
* @return \Engine\Mvc\Model
*/
public static function findFirst($parameters = null)
{
if (!static::$_conditions) {
return parent::findFirst($parameters);
}
$conditions = static::normalizeConditions(static::$_conditions);
if (!$parameters) {
return parent::findFirst($conditions);
}
if (is_string($parameters)) {
$parameters .= " AND " . $conditions;
} else {
$parameters[0] .= " AND " . $conditions;
}
return parent::findFirst($parameters);
}
示例13: findFirst
public static function findFirst($parameters = null, $autoCreate = false)
{
$parameters = self::getCacheableParams($parameters);
return parent::findFirst($parameters, $autoCreate);
}
示例14: findFirst
public static function findFirst($parameters = null)
{
$parameters = self::getCacheableParams($parameters);
return parent::findFirst($parameters);
}
示例15: findFirst
/**
* @inheritdoc
*
* @access public
* @static
* @param array|string $parameters Query parameters
* @return Phalcon\Mvc\Model
*/
public static function findFirst($parameters = null)
{
$parameters = self::softDeleteFetch($parameters);
return parent::findFirst($parameters);
}