Exemplo n.º 1
0
Arquivo: CRUD.php Projeto: jasny/Q
 /**
  * Add criteria to statement for each filter from array $filters
  * 
  * @param $statement
  * @param array $filters
  */
 protected function applyFilters($statement, $filters)
 {
     $db = $this->table->getConnection();
     foreach ($filters as $key => $value) {
         if (empty($value)) {
             continue;
         }
         list($field, $operator) = explode(' ', $key) + array(1 => null);
         $statement->addCriteria(strpos('.', $field) === false ? $db->makeIdentifier($this->table, $field) : DB::i()->quoteField($field), $value, $operator);
     }
 }
Exemplo n.º 2
0
Arquivo: Field.php Projeto: jasny/Q
 /**
  * Return the name of a field.
  *
  * @param int $flags  A DB::FIELDNAME_% constant and DB::WITH_ALIAS and DB::QUOTE_% options as binary set 
  * @return string
  */
 public function getName($flags = DB::FIELDNAME_FULL)
 {
     switch ($flags & 0xf) {
         case DB::FIELDNAME_NAME:
             return $flags & QUOTE_LOOSE || $flags & QUOTE_STRICT ? $this->parent->getConnection()->quoteIdentifier($this['name'], $flags) : $this['name'];
         case DB::FIELDNAME_FULL:
             return $flags & QUOTE_LOOSE || $flags & QUOTE_STRICT ? $this->parent->getConnection()->makeIdentifier($this['table'], $this['name'], $flags) : (isset($this['table']) ? $this['table'] . '.' . $this['name'] : $this['name']);
         case DB::FIELDNAME_COLUMN:
             return $this->parent->getConnection()->makeIdentifier($this['table'], $this['name_db'], $flags & DB::WITH_ALIAS && $this['name'] != $this['name_db'] ? $this['name'] : null, $flags);
         case DB::FIELDNAME_DB:
             return $this->parent->getConnection()->makeIdentifier($this['table_db'], $this['name_db'], $flags & DB::WITH_ALIAS && $this['name'] != $this['name_db'] ? $this['name'] : null);
     }
 }
Exemplo n.º 3
0
Arquivo: DB.php Projeto: jasny/Q
 /**
  * Log a message.
  *
  * @param string|array $message  Message or associated array with info
  * @param string       $type
  */
 public function log($message, $type = null)
 {
     if (!isset($type) && is_array($message) && isset($message['type'])) {
         $type = $message['type'];
     }
     if (isset($this->alias[$type])) {
         $type = $this->alias[$type];
     }
     if (!$this->shouldLog($type)) {
         return;
     }
     $values = array_merge($this->_eventValues->getAll(), isset($type) ? array('type' => $type) : array(), is_array($message) ? $message : array('message' => $message));
     $store = null;
     if (!isset($this->fields)) {
         $store =& $values;
     } else {
         foreach ($this->fields as $key => $field) {
             $store[$field] = isset($values[$key]) ? $values[$key] : null;
         }
     }
     $conn = $this->table instanceof DB_Table ? $this->table->getConnection() : DB::i();
     $conn->store($this->table, $values);
 }