Ejemplo n.º 1
0
 function values($table_name = '', $input = null)
 {
     if ($input === null) {
         $input = $this->input->in;
     }
     $columns = $this->column_names($table_name);
     $values = \Grithin\Arrays::extract($columns, $input, $v = [], false);
     return $values;
 }
Ejemplo n.º 2
0
 function checkUniqueKeys($value, $table, $type, $id = null)
 {
     $indices = $this->db->indices($table);
     foreach ($indices as $name => $key) {
         if ($key['unique']) {
             if ($name != 'PRIMARY') {
                 foreach ($key['columns'] as $column) {
                     if (!isset($this->input->in[$column]) || $this->input->in[$column] === null) {
                         //null indices can overlap
                         continue 2;
                     }
                 }
                 $where = Arrays::extract($key['columns'], $this->input->in);
                 if ($type != 'create' && $id) {
                     $where['id?<>'] = $id;
                 }
                 if ($this->db->check($table, $where)) {
                     Debug::toss(['type' => 'record_not_unique', 'detail' => $key['columns']], 'InputException');
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
Archivo: Db.php Proyecto: grithin/phpdb
 /**
 @note	insert ignore and insert update do not return a row id, so, if the id is not provided and the matchKeys are not provided, may not return row id
 @return will attempt to get row id, otherwise will return count of affected rows
 */
 protected function into($type, $table, $kvA, $update = '', $matchKeys = null)
 {
     $res = $this->query($type . ' INTO ' . $this->quoteIdentity($table) . $this->kvf($kvA) . $update);
     if ($this->under->lastInsertId()) {
         return $this->under->lastInsertId();
     } elseif ($kvA['id']) {
         return $kvA['id'];
     } elseif ($matchKeys) {
         $matchKva = Arrays::extract($matchKeys, $kvA);
         return $this->value($table, $matchKva, 'id');
     } else {
         return $res->rowCount();
     }
 }