Esempio n. 1
1
 /**
  * Retorna o login
  *
  * @param $parameters
  * @return bool|\Phalcon\Mvc\Model
  */
 public static function findLogin($parameters)
 {
     $email = $parameters['email'];
     $senha = $parameters['senha'];
     $row = parent::findFirst(['conditions' => 'email = ?1 AND senha = ?2 AND isdel = 0', 'bind' => [1 => $email, 2 => $senha]]);
     if ($row) {
         return $row;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 3
0
 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);
 }
 public static function findFirstAsArray($id, $pullDocuments = false)
 {
     $p = parent::findFirst($id);
     $p = $p->toArray();
     if ($pullDocuments) {
         $p['documents'] = Documents::findByProjectId($id);
     }
     return $p;
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 /**
  * 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;
     }
 }
Esempio n. 7
0
 /**
  * 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);
 }
Esempio n. 8
0
 /**
  * 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);
 }
Esempio n. 9
0
 /**
  * @return User
  */
 public static function findFirst($parameters = array())
 {
     return parent::findFirst($parameters);
 }
Esempio n. 10
0
 public static function findFirst($parameters = null)
 {
     $needFind = array_merge($parameters, self::$needGet);
     return parent::findFirst($needFind);
 }
Esempio n. 11
0
 /**
  * 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)));
 }
Esempio n. 12
0
 public static function findFirst($parameters = NULL)
 {
     $result = parent::findFirst($parameters = null);
     $_oldTags = $result->tags;
     return $result;
 }
Esempio n. 13
0
 /**
  * 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);
 }
Esempio n. 14
0
 public static function findFirst($parameters = null, $autoCreate = false)
 {
     $parameters = self::getCacheableParams($parameters);
     return parent::findFirst($parameters, $autoCreate);
 }
Esempio n. 15
0
 public static function findFirst($parameters = null)
 {
     $parameters = self::getCacheableParams($parameters);
     return parent::findFirst($parameters);
 }
Esempio n. 16
0
 /**
  * @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);
 }