Appends a line to a query that is being built line by line

@param string $data Line of SQL data or NULL to initialize a new query
@return string SQL query string.
354820
function buildQuery( $sql = NULL ) {
		if( !isset( $this->query ) OR empty( $sql ) ) {
			return FALSE;
		}

		$this->query .= $sql;

		return $this->query;
	}
1169390
final public function create(array $data)
    {
        $this->query->setStartInsert($data);
        
        $this->query->prepare()->bindValuesForInsert($data)->execute();

        $this->setRowCount();

        $this->query->close();
    }
69552
private function _buildSet($data)
    {
        $columns = [];

        foreach($data as $key=>$value)
            $columns[] = sprintf('`%s`=?',$key);

        return implode(', ', $columns);
    }
996562
public function query(string $sql, $data = null) {
		$connection = $this->pool->getConnection();
		$result = null;
		$tryAgain = true;
SQL_START_EXECUTE:
		if (is_array($data) && count($data) > 0) {
			if (strpos($sql, ':') !== false) {
				$bind = [];
				$sql = preg_replace_callback('/:(\w+)\b/', function ($matches) use (&$data, &$bind) {
					$bind[] = $data[$matches[1]];
					return '?';
				}, $sql);
				$data = &$bind;
			}
			try {
				$st = $connection->prepare($sql);
				if ($st === false) {
					goto SQL_TRY_AGAIN;
				}
				if (is_object($st)) {
					$result = $st->execute($data);
				} else {
					$result = $connection->execute($data);
				}
			} catch (\Throwable $e) {
				goto SQL_TRY_AGAIN;
			}
			if ($result === false) {
				goto SQL_TRY_AGAIN;
			}
			goto SQL_SUCCESS_RETURN;
		} else {
			try {
				$result = $connection->query($sql);
			} catch (\Throwable $e) {
				goto SQL_TRY_AGAIN;
			}
			if ($result === false) {
				goto SQL_TRY_AGAIN;
			}
			goto SQL_SUCCESS_RETURN;
		}
SQL_TRY_AGAIN:
		if (($connection->errno === 2006 || $connection->errno === 2013) && $tryAgain) {
			$tryAgain = false;
			$connection = $this->pool->reconnect($connection);
			goto SQL_START_EXECUTE;
		} else {
			$error = $connection->error;
			$errno = $connection->errno;
			$this->pool->freeConnection($connection);
			throw new DBException($error, $errno);
		}
SQL_SUCCESS_RETURN:
		if ($result === true) {
			$result = [
				'_affected_rows' => $connection->affected_rows
			];
			if (stripos($sql, 'insert') === 0) {
				$result['_insert_id'] = $connection->insert_id;
			}
		}
		$this->pool->freeConnection($connection);
		return $result;
	}
1207895
public function add($data = [])
    {
        $this->connection();
        $db = DB::table($this->table);
        $id = $db->insertGetId($data);
        $this->debug->debug(__FUNCTION__, 'SQL Queries: ' . $db->toSql());
        $this->debug->debug(__FUNCTION__, 'Result Insert ID: ' . $id);

        return $id;
    }
1237657
protected function buildQuery($data = null)
    {
        $params = array();

        if ($data instanceof Criteria) {
            $params = array_merge($params, $data->getParams());
            $params['orderBy'] = $data->getOrderBy();
        }

        if ($token = $this->getOption('token', false)) {
            $params['auth'] = $token;
        }

        return $params;
    }
32400
public function appendData(string $data): self
    {
        if (empty($this->nodes)) {
            $prevHash = $this->firstPrevHash;
        } else {
            $last = $this->getLastNode();
            $prevHash = $last->getHash(true);
        }
        $newNode = new Node($data, $prevHash);
        $this->nodes[] = $newNode;

        SodiumCompat::crypto_generichash_update(
            $this->summaryHashState,
            $newNode->getHash(true)
        );
        return $this;
    }
770529
protected function exportInsert(array $data)
    {
        $insertSql = '';
        $insert = new Insert(self::TABLE_NAME);
        foreach ($data as $id => $value) {
            $insertSql .= @$insert
                ->values(array('id' => $id, 'value' => $value))
                ->getSqlString($this->getPlatform()).';'.PHP_EOL;
        }

        return $insertSql;
    }
78229
function update($data)
    {
        $update = "";
        foreach ($data as $key => $value)
        {
            $value = $this->db->quote($value);
            if ($value != '' and $value{0} == '`')
            {
                $update = $update . "`$key`=$value,";
            }
            else
            {
                $update = $update . "`$key`='$value',";
            }
        }
        $update = substr($update, 0, -1);
        return $this->db->query("update {$this->table} set $update {$this->where} {$this->limit}");
    }
14430
public function addRow($data = null)
    {
        // Clear existing empty row
        if (($current = $this->currentRow()) && $current->isEmpty()) {
            array_pop($this->rows);
        }

        // Append data
        if ($data instanceof SQLAssignmentRow) {
            $this->rows[] = $data;
        } else {
            $this->rows[] = new SQLAssignmentRow($data);
        }
        return $this;
    }
749128
public function appendIni($data)
    {
        $array = parse_ini_string($data, $this->_processIniSection, INI_SCANNER_RAW);

        if ($array === false) {
            $this->_hasErrors = true;
            $this->_errorsList[] = 'parse_ini_string';
            return $this;
        }

        $this->appendArray($array);
        return $this;
    }
584357
protected static function buildQuestionMarks($data)
    {
        $row = self::getFirstRow($data);
        $questionMarks = array_fill(0, count($row), '?');

        $line = '(' . implode(',', $questionMarks) . ')';
        $lines = array_fill(0, count($data), $line);

        return implode(', ', $lines);
    }
218519
public function writeLine($data)
    {
        if (!is_resource($this->fp)) {
            return $this->raiseError('not connected');
        }

        return fwrite($this->fp, $data . $this->newline);
    }
136525
protected static function buildReplaceSql(array $data)
    {
        $first = static::getFirstRow($data);

        $sql  = 'REPLACE INTO `' . static::getTablePrefix() . static::getTableName() . '`(' . static::getColumnList($first) . ') VALUES' . PHP_EOL;
        $sql .=  static::buildQuestionMarks($data);

        return $sql;
    }
726986
public function add($data /* $data = null, ... */)
    {
        // bogus "usage" of parameter $data: scrutinizer warns this variable is
        // not used (we're using func_get_args instead to support overloading),
        // but it still needs to be defined because it makes no sense to have
        // this function without argument :)
        $args = array($data) + func_get_args();

        // this method can be overloaded
        foreach ($args as $data) {
            if (is_array($data)) {
                call_user_func_array(array($this, 'add'), $data);
                continue;
            }

            // redefine var
            $data = (string) $data;

            // load data
            $value = $this->load($data);
            $key = ($data != $value) ? $data : count($this->data);

            // replace CR linefeeds etc.
            // @see https://github.com/matthiasmullie/minify/pull/139
            $value = str_replace(array("\r\n", "\r"), "\n", $value);

            // store data
            $this->data[$key] = $value;
        }

        return $this;
    }
1197121
public function insert(array $data)
    {
        $params = array();
        $query = "INSERT INTO $this->_name (";

        foreach ($data as $key => $value) {
            $query .= "$key, ";

        }

        $query = substr($query, 0, -2);
        $query .= ") VALUES (";

        $iValue = 0;
        foreach ($data as $key => $value) {
            $query .= ":value$iValue, ";
            $params[":value$iValue"] = $value;
            $iValue++;
        }

        $query = substr($query, 0, -2);
        $query .= ")";

        return $this->_insert($query, $params);
    }
77197
public function create(array $data)
    {
        // Creates the keys string
        $keys = implode(', ', array_keys($data));

        // Creates the values string
        $values = implode('", "', $data);

        // Creates the query with the $data array keys & values
        $query = 'INSERT INTO ' . $this->table . ' (' . $keys . ') VALUES ("' . $values . '")';

        // Executes the query
        $this->database->action($query);
    }