Aktualizacja rekordów
@param string $table nazwa tabeli
@param array $data tabela w postaci: klucz => wartość
@param array $whereBind warunek w postaci zagnieżdżonego bind
@return integer
553795
public function update($table, array $data = [], $where = '', array $whereBind = [])
    {
        $fields = '';
        $bind = [];
        //jeśli brak danych wyjście z metody
        if (empty($data)) {
            return 1;
        }
        //wiązanie parametrów
        foreach ($data as $key => $value) {
            $bindKey = PdoBindHelper::generateBindKey();
            $fields .= $this->prepareField($key) . ' = :' . $bindKey . ', ';
            $bind[$bindKey] = $value;
        }
        //budowanie zapytania aktualizującego
        $sql = 'UPDATE ' . $this->prepareTable($table) . ' SET ' . rtrim($fields, ', ') . ' ' . $where;
        return $this->query($sql, array_merge($bind, $whereBind))->rowCount();
    }
448960
public function insertPDO($table, array $data = array())
    {
        if (count($data) === 0) {
            return false;
        }
        $q = "INSERT INTO `$table` ";
        $v = '';
        $n = '';

        foreach ($data as $key => $val) {
            $n .= "`$key`, ";
            if (strtolower($val) === 'now()') {
                $v .= 'NOW(), ';
                unset($data[$key]);
            } else {
                $v .= '?, ';
            }
        }
        $q .= '(' . rtrim($n, ', ') . ') VALUES (' . rtrim($v, ', ') . ');';
        try {
            $this->_queryId = self::$_linkId->prepare($q);

            $i = 1;
            foreach ($data as $key => $val) {
                $type = $this->getPDOConstantType($val);
                $this->_queryId->bindValue($i, $val, $type);
                ++$i;
            }
            $this->_queryId->execute();
            return self::$_linkId->lastInsertId();
        } catch (PDOException $e) {
            $this->_error = $e->getMessage();
            return false;
        }
    }
45800
public function update($data, $where = [])
    {
        /*
         | Trigger Before Update events if
         | defined by user into model class
         |
         */
        $this->triggerEvent('beforeUpdate');

        if (!empty($where)) {
            $whereStr = $this->buildWherePlaceholderName($where);
        } else {
            list($where, $whereStr) = $this->buildWhereForUpdate();
        }

        $sql = $this->getUpdateQuery($data, strtoupper(__FUNCTION__)).$whereStr;

        try {
            $stmt = $this->resolveConnection()->prepare($sql);

            //Bind all values to query statement
            foreach ($data as $key => $val) {
                $stmt->bindValue(":$key", $val);
            }

            foreach ($where as $key => $value) {
                $stmt->bindValue(":$key", $value);
            }

            static::$queries[] = $stmt->queryString;
            $affectedRow = $stmt->execute();

            /*
             | Trigger after update events if defined
             | into model class
             |
             */
            $this->triggerEvent('afterUpdate');

            return $affectedRow;
        } catch (\PDOException  $exception) {
            throw new \Exception($exception->getMessage());
        }
    }
41358
public static function delete($table, $where = null) {
        if ($where) {
            Delete::delete($table, $where);
        } else {
            return Delete::table($table);
        }
        return null;
    }
389927
private static function parseSql($table,$where,$option=[])
    {
        $field='';
        if(isset($option['field']) && is_array($option['field'])){
            $ends=count($option['field'])-1;
            foreach ($field as $key => $value) {
                $field.='`'.$value.'`';
                if($key!=$ends){
                    $field.=',';
                }
            }
        }else{
            $field='*';
        }
        $limit='';
        if(isset($option['limit']) && is_array($option['limit'])){
            $limit=' LIMIT '.$option['limit'][0].','.$option['limit'][1];
        }
        $order='';
        if(isset($option['order']) && is_array($option['order'])){
            $c=count($option['order'])-1;
            $i=0;
            $order='ORDER BY ';
            foreach ($option['order'] as $key=>$value) {
                $i++;
                $order.="`{$key}` {$value}";
                if($c==$i){
                    $order.=',';
                }
            }

        }
        $bind=[];
        if(empty($where)){
            $where='';
        }else{
            $w=new Where($where);
            $where=' WHERE '.$w->parseWhere();
            $bind=array_merge($bind,$w->parseBind());
        }

        $sql=sprintf('SELECT '.$field.' FROM `:%s` %s %s %s',$table,$where,$limit,$order);
        return self::query($sql,$bind);
    }
318319
public function responseFilter($data, $table = '')
    {
        /* suka lupa ini object nya propel */
        if (is_object($data)) {
            $data = $data->toArray();
        }
        if ($table === '' && empty(static::DEFAULT_TABLE)) {
            return $data;
        } elseif ($table === '' && !empty(static::DEFAULT_TABLE)) {
            $table = static::DEFAULT_TABLE;
        }

        $excludeFields = Config::getConfig('excludeFields');
        if (!in_array($table, $excludeFields)) {
            return $data;
        } else {
            $tempData = $data;
            if (isset($tempData[0])) { // MULTIDIMENTIAL ARRAY
                foreach ($tempData as $k => $v) {
                    foreach ($v as $index => $value) {
                        if (is_array($value)) {
                            $tempData[$k][$index] = $this->responseFilter($value, $index);
                        } else {
                            foreach ($excludeFields[$table] as $exKey => $exVal) {
                                unset($tempData[$k][$exVal]);
                            }
                        }
                    }
                }
            } else { // SINGLE ARRAY
                foreach ($tempData as $index => $value) {
                    if (is_array($value)) {
                        $tempData[$k][$index] = $this->responseFilter($value, $index);
                    } else {
                        foreach ($excludeFields[$table] as $exKey => $exVal) {
                            unset($tempData[$k][$exVal]);
                        }
                    }
                }
            }
            return $tempData;
        }
    }
1088277
public function insert($table, array $bind)
    {
        $this->_connect();
        $newbind = array();
        if (is_array($bind)) {
            foreach ($bind as $name => $value) {
                if($value !== null) {
                    $newbind[$name] = $value;
                }
            }
        }

        return parent::insert($table, $newbind);
    }
521412
public static function update(array $data, array $where): int
    {
        $self = static::getInstance();

        $data = static::filterColumns($data);

        if (!\count($data)) {
            throw new DbException(
                "Invalid field names of table `{$self->name}`. Please check use of `update()` method"
            );
        }

        $where = static::filterColumns($where);

        if (!\count($where)) {
            throw new DbException(
                "Method `Table::update()` can't update all records in the table `{$self->name}`,\n" .
                "please use `Db::query()` instead (of cause if you know what are you doing)"
            );
        }

        $table = DbProxy::quoteIdentifier($self->name);

        $sql = "UPDATE $table SET " . implode(',', self::prepareStatement($data))
            . " WHERE " . implode(' AND ', self::prepareStatement($where));

        return DbProxy::query($sql, array_merge(array_values($data), array_values($where)));
    }
889601
public function GetDelete($Table, $Where, &$Data) {
      if (is_array($Data)) {
         // Grab the records.
         $Result = $this->SQL->GetWhere($Table, $Where)->ResultArray();
         
         if (empty($Result))
            return;
         
         // Put the records in the result array.
         if (isset($Data[$Table])) {
            $Data[$Table] = array_merge($Data[$Table], $Result);
         } else {
            $Data[$Table] = $Result;
         }
      }
      
      $this->SQL->Delete($Table, $Where);
   }
231405
public function query($sql, array $bind = [])
    {
        //łączy jeśli niepołączony
        if (!$this->_connected) {
            $this->connect();
        }
        //czas startu na potrzeby profilera
        $start = microtime(true);
        //wybór PDO (zapis lub odczyt)
        $pdo = (preg_match('/^SELECT/i', $sql) && !$this->_transactionInProgress) ? $this->_downstreamPdo : $this->_upstreamPdo;
        //przygotowywanie zapytania
        $statement = $pdo->prepare($sql);
        //błędne zapytanie
        if (!$statement) {
            $error = $pdo->errorInfo();
            throw new DbException(get_called_class() . ': ' . (isset($error[2]) ? $error[2] : $error[0]) . ' --- ' . $sql);
        }
        //wiązanie parametrów do zapytania
        foreach ($bind as $key => $param) {
            //domyślnie typ jako string
            $type = \PDO::PARAM_STR;
            //jeśli bool to bool
            if (is_bool($param)) {
                $type = \PDO::PARAM_BOOL;
            }
            //jeśli kluczem jest liczba (przy insertach), zwiększamy licznik o 1
            if (is_int($key)) {
                $key = $key + 1;
            }
            //wiązanie wartości
            $statement->bindValue($key, $param, $type);
        }
        //wykonywanie zapytania
        $result = $statement->execute();
        //przypisanie rezultatu do zmiennej w statement
        $statement->result = $result;
        //jeśli rezultat to nie 1, wyrzucony zostaje wyjątek bazodanowy
        if ($result != 1) {
            $error = $statement->errorInfo();
            $error = isset($error[2]) ? $error[2] : $error[0];
            throw new DbException(get_called_class() . ': ' . $error . ' --- ' . $sql);
        }
        //jeśli profiler włączony, dodanie eventu
        $this->_profiler ? $this->_profiler->event($statement, $bind, microtime(true) - $start) : null;
        return $statement;
    }
727849
public function insert($table, array $bind)
    {
        // extract and quote col names from the array keys
        $cols = array();
        $vals = array();
        $i = 0;
        foreach ($bind as $col => $val) {
            $cols[] = $this->quoteIdentifier($col, true);
            if ($val instanceof Zend_Db_Expr) {
                $vals[] = $val->__toString();
                unset($bind[$col]);
            } else {
                if ($this->supportsParameters('positional')) {
                    $vals[] = '?';
                } else {
                    if ($this->supportsParameters('named')) {
                        unset($bind[$col]);
                        $bind[':col'.$i] = $val;
                        $vals[] = ':col'.$i;
                        $i++;
                    } else {
                        /** @see Zend_Db_Adapter_Exception */
                        // require_once 'Zend/Db/Adapter/Exception.php';
                        throw new Zend_Db_Adapter_Exception(get_class($this) ." doesn't support positional or named binding");
                    }
                }
            }
        }

        // build the statement
        $sql = "INSERT INTO "
             . $this->quoteIdentifier($table, true)
             . ' (' . implode(', ', $cols) . ') '
             . 'VALUES (' . implode(', ', $vals) . ')';

        // execute the statement and return the number of affected rows
        if ($this->supportsParameters('positional')) {
            $bind = array_values($bind);
        }
        $stmt = $this->query($sql, $bind);
        $result = $stmt->rowCount();
        return $result;
    }
1292548
public function insert($table, $data) {
        if (!is_array($data)) {
            return false;
        }

        $fragment_sql = $this->prepareBinding($data, ', ');
        $bind_values = array_values($data);
        $query = 'INSERT `'. $table.'` SET ' . $fragment_sql;

        return $this->run($query, $bind_values);
    }
1115659
public function updateRows(string $table, array $set, array $where): int
    {
        $update = new Update($this->options);
        $sqlParams = $update->buildQuery($table, $set, $where);
        return $this->query($sqlParams->getSql(), $sqlParams->getParams())->getAffected();
    }
576932
public function insert($table, array $data = [])
    {
        $fields = '';
        $values = '';
        $bind = [];
        //wiązanie placeholderów "?" w zapytaniu z parametrami do wstawienia
        foreach ($data as $key => $value) {
            $fields .= $this->prepareField($key) . ', ';
            $values .= '?, ';
            $bind[] = $value;
        }
        //budowanie wstawiającego SQL
        $sql = 'INSERT INTO ' . $this->prepareTable($table) . ' (' . rtrim($fields, ', ') . ') VALUES(' . rtrim($values, ', ') . ')';
        return $this->query($sql, $bind)->rowCount();
    }
1305106
public function getWhere(string $table, $where=[], $limit=FALSE, $offset=FALSE): ?PDOStatement
	{
		// Create the where clause
		$this->where($where);

		// Return the result
		return $this->get($table, $limit, $offset);
	}
599397
public function insertRow($table, array $settings, $bind = true)
    {
        //argument test
        Argument::i()
            //Argument 1 must be a string
            ->test(1, 'string')
            //Argument 3 must be an array or bool
            ->test(3, 'array', 'bool');
        
        //build insert query
        $query = $this->insert($table);
        
        //foreach settings
        foreach ($settings as $key => $value) {
            //if value is not a vulnerability
            if (is_null($value) || is_bool($value)) {
                //just add it to the query
                $query->set($key, $value);
                continue;
            }
            
            //if bind is true or is an array and we want to bind it
            if ($bind === true || (is_array($bind) && in_array($key, $bind))) {
                //bind the value
                $value = $this->bind($value);
            }
            
            //add it to the query
            $query->set($key, $value);
        }
        
        //run the query
        $this->query($query, $this->getBinds());
        
        //event trigger
        $this->trigger('sql-insert', $table, $settings);
        
        return $this;
    }
953038
public function dbUpdate($table, $data, $condition = '')
    {
        if (is_array($data))
        {
            if (empty($condition)) $condition = 'id';
            $result = Eresus_CMS::getLegacyKernel()->db->
                updateItem($this->__table($table), $data, "`$condition` = '{$data[$condition]}'");
        }
        elseif (is_string($data))
        {
            $result = Eresus_CMS::getLegacyKernel()->db->
                update($this->__table($table), $data, $condition);
        }
        else
        {
            $result = false;
        }

        return $result;
    }