@param array      $table
@param array      $data
@param Condition  $where
@param BindValues $values
@param array      $order
@param array      $limit

@return string
163898
public function getUpdateSQL($table, $data, $where, $values, $order, $limit) {
        $len = count($table);
        if ($len == 1) {
            $sql = ['UPDATE', implode(' AS ', $table[0]), 'SET'];
        } else {
            $tables = [];
            foreach ($table as $t) {
                $tables[] = implode(' AS ', $t);
            }
            $sql = ['UPDATE', implode(' , ', $tables), 'SET'];
        }

        $fields = [];
        foreach ($data as $field => $value) {
            $field = Condition::cleanField($field);
            if ($value instanceof Query) {
                $value->setBindValues($values);
                $value->setDialect($this);
                $fields [] = $this->sanitize($field) . ' =  (' . $value->__toString() . ')';
            } else if ($value instanceof ImmutableValue) {
                $value->setDialect($this);
                $fields [] = $this->sanitize($field) . ' =  ' . $this->sanitize($value->__toString());
            } else {
                $fields [] = $this->sanitize($field) . ' = ' . $values->addValue($field, $value);
            }
        }

        $sql [] = implode(' , ', $fields);
        if ($where && count($where) > 0) {
            $sql [] = 'WHERE';
            $sql [] = $where->getWhereCondition($this, $values);
        }

        if ($len == 1) {
            if ($order) {
                $_orders = [];
                foreach ($order as $o) {
                    $_orders [] = Condition::cleanField($o [0]) . ' ' . ($o [1] == 'a' ? 'ASC' : 'DESC');
                }
                $sql [] = 'ORDER BY ' . implode(' , ', $_orders);
            }
            if ($limit) {
                $limit2 = $values->addValue('limit', $limit [1]);
                $sql [] = 'LIMIT ' . $limit2;
            }
        }

        return implode(' ', $sql);
    }
681803
public function update($table, $data, $statements, $where)
    {
        $query = 'UPDATE `' . $table . '`  SET ';

        foreach ($data as $column => $value) {
            $value = (is_null($statements) && is_string($value)) ? "'$value'" : $value;
            $query .= $column . '=' . $value . ', ';
        }

        $query = rtrim(trim($query), ',');

        $query .= (! is_null($where)) ? ' WHERE ' : '';

        $query .= (is_string($where)) ? $where . ' ' : '';

        if (is_array($where)) {
            foreach ($where as $clause) {
                $query .= $clause . ' AND ';
            }
            $query = rtrim(trim($query), 'AND');
        }

        if (! is_null($statements) && is_array($statements)) {
            return $this->statements($query, $statements);
        }

        return $this->query($query, 'INSERT');
    }
422786
public function fieldSelect($table, $fields, $where, $orderBy = null)
    {
        $table = $this->getTableName($table);

        $query = "SELECT ";

        if (substr($this->mode, 0, 5) === "mssql") {
            $query .= "TOP 1 ";
        }

        $query .= $this->selectFields($fields);

        $query .= " FROM " . $table . " ";

        $params = null;
        if ($where !== self::NO_WHERE_CLAUSE) {
            $query .= "WHERE " . $this->where($where, $params);
        }

        if ($orderBy) {
            $query .= $this->orderBy($orderBy) . " ";
        }

        switch ($this->mode) {

            case "mysql":
            case "postgres":
            case "redshift":
            case "sqlite":
                $query .= "LIMIT 1";
                break;

            case "odbc":
                $query .= "FETCH FIRST 1 ROW ONLY";
                break;
        }

        return $this->query($query, $params)->fetch();
    }
1250362
public function update($table = '', $data = [], $arrayWhere = [], $other = '')
    {
        // if table name is empty
        if (!empty($table)) {
            // check if array data and where array is more then 0
            if (count($data) > 0 && count($arrayWhere) > 0) {
                // parse array data and make a temp array
                $tmp = [];
                foreach ($data as $k => $v) {
                    $tmp[] = "$k = :s_$k";
                }
                // join temp array value with ,
                $sFields = implode(', ', $tmp);
                // delete temp array from memory
                unset($tmp);

                $tmp = [];
                // parse where array and store in temp array
                foreach ($arrayWhere as $k => $v) {
                    $tmp[] = "$k = :s_$k";
                }

                $this->data = $data;
                $this->arrayWhere = $arrayWhere;
                // join where array value with AND operator and create where condition
                $where = implode(' AND ', $tmp);
                // unset temp array
                unset($tmp);
                // make sql query to update
                $this->sql = "UPDATE `$table` SET $sFields WHERE $where $other;";
                // on PDO prepare statement
                $this->STH = $this->prepare($this->sql);
                // bind pdo param for update statement
                $this->_bindPdoNameSpace($data);
                // bind pdo param for where clause
                $this->_bindPdoNameSpace($arrayWhere);
                // try catch block start
                try {
                    // if PDO run
                    if ($this->STH->execute()) {
                        // get affected rows
                        $this->affectedRows = $this->STH->rowCount();
                        // close PDO
                        $this->STH->closeCursor();
                        // return self object
                        return $this;
                    } else {
                        self::error($this->STH->errorInfo());
                    }
                } catch (\PDOException $e) {
                    // get pdo error and pass on error method
                    self::error($e->getMessage() . ': ' . __LINE__);
                } // try catch block end
            } else {
                self::error('update statement not in valid format..');
            }
        } else {
            self::error('Table name not found..');
        }
    }
69678
public function sqlUpdate(
		$table,
		array $properties,
		$where,
		array $where_params = [],
		$limit = null
	) {
		$attributes = [];
		foreach ($properties as $attribute => $value) {
			$attributes[] = $attribute . ' = :U' . $attribute; // name parameters after attribute
			if (array_key_exists(':U' . $attribute, $where_params)) {
				throw new Exception('Named parameter already defined: ' . $attribute);
			}
			$where_params[':U' . $attribute] = $value;
		}
		$sql = $this->queryBuilder->buildUpdate($table, $attributes, $where, $limit);
		$query = $this->database->prepare($sql);
		$query->execute($where_params);
		$this->addQuery($query->queryString, $where_params);
		return $query->rowCount();
	}
506210
public function select($table, $fields = "*", $where = ' ', $order = '', $limit = null, $offset = null, $array = array (), $fetchMode)
    {
        // TODO: Implement select() method.
    }
1006863
public function get_select_sql( $tables, $where = null, $fields = null, $limit = null, $offset = null, $order_by = null, $group_by = null, $for_update = false ) {
		$as = null;
		if ( is_array( $tables ) ) {
			if ( empty( $tables ) ) {
				return false;
			}
			$table = array_shift( $tables );
			$join  = $tables;
			if ( count( $table ) > 1 ) {
				$as = $table[1];
			}
			$table = $table[0];
		} else {
			$table = $tables;
			$join  = null;
		}
		if ( ! isset( $this->table_defines[ $table ] ) ) {
			return false;
		}

		$columns = $this->table_defines[ $table ]['columns'];

		! is_array( $where ) and $where = [];
		if ( $this->is_logical( $this->table_defines[ $table ] ) ) {
			$where['deleted_at'] = null;
		}

		list( $conditions, $values ) = $this->build_conditions( $where, $columns );
		$table  = $this->get_table( $table );
		$fields = $this->build_fields( $fields, $columns );
		$sql    = "SELECT {$fields} FROM $table";
		if ( isset( $as ) ) {
			$sql .= " AS $as";
		}
		$sql .= $this->build_join( $join );
		if ( ! empty( $conditions ) ) {
			$sql .= " WHERE $conditions";
		}
		$sql .= $this->build_group_by( $group_by, $columns );
		$sql .= $this->build_order_by( $order_by, $columns );
		$sql .= $this->build_limit( $limit, $offset );
		if ( $for_update ) {
			$sql .= ' FOR UPDATE';
		}

		return $this->prepare( $sql, $values );
	}
1212951
public function getByOrder(string $orderBy, array $where = [], array $with = [], string $order = 'desc', int $limit = 0)
    {
        $query = $this->make($with);

        $query = $this->applyWhere($query, $where);

        $query = $query->orderBy($orderBy, $order);

        if ($limit) {
            $query = $query->take($limit);
        }

        return $query->get();
    }
418982
public static function findColumns (array $columns, int $limit=0, string $order="DESC")
	{
		$order 	   	= static::validateOrder($order);
        $dbObject  	= Database::getInstance();
		$columns 	= joinArray($dbObject->escapeValues($columns), ', ');
		return static::limitFindBySql("SELECT {$columns} FROM ".static::$tableName." ORDER BY id {$order}", $limit);
	}
800261
public function update($table, $feilds, array $where, $limit=0)
	{
		$set = array();
        $vals = array();

		foreach ($feilds as $key => $val) {
			$set[] = "`{$key}` = ?";
            $vals[] = $val;
		}

		$set = implode(', ', $set);

		$sql = "UPDATE {$table} SET {$set} WHERE " . $this->buildWhere($where, $vals);

        if ($limit > 0) {
            $sql .= " LIMIT ".(int)$limit;
        }

        $stmt = $this->prepare($sql);
        return $stmt ? $stmt->execute($vals) : false;
	}
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;
        }
    }
1187263
public function update($table, $data, $where, $limit = null)
    {
        $query = $this->provider->buildUpdateQuery($table, $data, $where, $limit);

        return $this->provider->query($query, null);
    }
918642
public function insert($table, array $bind)
    {
        // extract and quote col names from the array keys
        $cols = array();
        $vals = array();
        foreach ($bind as $col => $val) {
            $cols[] = $this->quoteIdentifier($col, true);
            if ($val instanceof Zend_Db_Expr) {
                $vals[] = $val->__toString();
                unset($bind[$col]);
            } else {
                $vals[] = '?';
            }
        }

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

        // execute the statement and return the number of affected rows
        $stmt   = $this->query($sql, array_values($bind));
        $result = $stmt->rowCount();

        $stmt->nextRowset();

        $this->_lastInsertId = $stmt->fetchColumn();

        return $result;
    }
1024292
public function HtmlEntityDecode($Table, $Column, $Limit = 100) {
      // Construct a model to save the results.
      $Model = $this->CreateModel($Table);
      
      // Get the data to decode.
      $Data = $this->SQL
         ->Select($Model->PrimaryKey)
         ->Select($Column)
         ->From($Table)
         ->Like($Column, '&%;', 'both')
         ->Limit($Limit)
         ->Get()->ResultArray();
      
      $Result = array();
      $Result['Count'] = count($Data);
      $Result['Complete'] = FALSE;
      $Result['Decoded'] = array();
      $Result['NotDecoded'] = array();
      
      // Loop through each row in the working set and decode the values.
      foreach ($Data as $Row) {
         $Value = $Row[$Column];
         $DecodedValue = HtmlEntityDecode($Value);
         
         $Item = array('From' => $Value, 'To' => $DecodedValue);
         
         if ($Value != $DecodedValue) {
            $Model->SetField($Row[$Model->PrimaryKey], $Column, $DecodedValue);
            $Result['Decoded'] = $Item;
         } else {
            $Result['NotDecoded'] = $Item;
         }
      }
      $Result['Complete'] = $Result['Count'] < $Limit;
      
      return $Result;
   }
578062
public function insert($table, array $data)
    {
        $table = $this->getTable($table);
        $field = implode(', ', array_keys($data));

        $placeholder = array();
        foreach ($data as $key => $value) {
            if ($value instanceof \stdClass && isset($value->scalar)) {
                $placeholder[] = $value->scalar;
                unset($data[$key]);
            } else {
                $placeholder[] = '?';
            }
        }
        $placeholder = implode(', ', $placeholder);

        $query = "INSERT INTO $table ($field) VALUES ($placeholder)";
        return $this->executeUpdate($query, array_values($data));
    }
719676
public function update($table, array $data, $where = [], array $bind = [])
    {
        $table  = $this->quote()->identifier($table);
        $fields = [];
        foreach ($data as $field => $value) {
            $fields[] = $this->quote()->into("{$field} = ?", $value);
        }
        $sql = "UPDATE $table SET " . implode(', ', $fields);
        if (is_array($where)) {
            $where = $this->createWhereExpression($where);
        }
        $sql .= (($where) ? " WHERE {$where}" : '');

        $stmt = $this->query($sql, $bind);

        return $stmt->rowCount();
    }
326577
function insertSql($table, array $bind)
    {
        // extract and quote col names from the array keys
        $cols = array();
        $vals = array();
        $this->extractAndQuoteCols($bind, $cols, $vals);
        // build the statement
        $sql = "INSERT INTO "
            . $this->wrappedAdapter->quoteIdentifier($table, true)
            . ' (' . implode(', ', $cols) . ') '
            . 'VALUES (' . implode(', ', $vals) . ')';
        return $sql;
    }