Metodo privado que construlle la sentencia <b>SQL</b>.
@return boolean retorna <b>true</b> si es todo correcto y <b>false</b> en caso de errores.
351710
private final function build() {
        $temp = false;
        $str  = "";
        $tok  = explode("?", $this->sql);        

        try {
            //saber si la longitud de paramtros ? si son mayores que cero.
            $this->int = count($tok)-1 > 0 ? count($tok)-1 : 0;
               
            //saber si la longitud de interrogantes es igual a la longitud de parametros.
            if ($this->cima <= $this->int && $this->cima >= 0 && $this->list->lenght() <= $this->int) {

                //reemplasar interrogantes por parametros.
                for ($i = 0; $i <= $this->cima; $i++) {
                    $str = $str.$tok[$i].$this->list->shift().' ';
                }

                //saber si el remplaso fue exitoso.
                if (strlen($str) > 0) {
                    $this->generate  = $str;
                    $temp = true;
                }

            } else {
                die('Error longitud no admitida. ');
            }
            
        } catch (\Exception $exc) {
            $temp = false;
            
        } finally {
            return $temp;
            
        }
    }
598603
public function getSql()
    {
        if ($this->isEmpty()) {
            throw new Exception("Invalid segment, please specify a valid segment.");
        }
        $sql = '';
        $subExpression = false;
        foreach ($this->tree as $expression) {
            $operator = $expression[self::INDEX_BOOL_OPERATOR];
            $operand = $expression[self::INDEX_OPERAND];

            if ($operator == self::BOOL_OPERATOR_OR
                && !$subExpression
            ) {
                $sql .= ' (';
                $subExpression = true;
            } else {
                $sql .= ' ';
            }

            $sql .= $operand;

            if ($operator == self::BOOL_OPERATOR_AND
                && $subExpression
            ) {
                $sql .= ')';
                $subExpression = false;
            }

            $sql .= " $operator";
        }
        if ($subExpression) {
            $sql .= ')';
        }
        return array(
            'where' => $sql,
            'bind'  => $this->valuesBind,
            'join'  => implode(' ', $this->joins)
        );
    }
987293
protected function describe()
	{
		if(is_null($this->_tableName) == false)
		{
			$this->_query = 'DESCRIBE '.$this->_tableName;
            if($this->_db->execute($this->_query) !== false)
			{
				$res = $this->_db->getAllRows();
                unset($this->_fields);
                unset($this->_primaryKey);
                $this->_fields = array();
                foreach($res as $r)
                {
                    $this->_fields[] = $r['Field'];
                    if($r['Key'] == 'PRI')
                    	$this->_primaryKey = $r['Field'];
                }
				return true;
			}
		}
		return false;
	}
422209
public function errorInfo()
    {
        $error = $this->errorCode();
        if ($error === false){
            return false;
        }

        /*
         * Return three-valued array like PDO.  But DB2 does not distinguish
         * between SQLCODE and native RDBMS error code, so repeat the SQLCODE.
         */
        return array(
            $error,
            $error,
            db2_stmt_errormsg()
        );
    }
1210077
public function from()
    {
        $from = '';

        $numargs = func_num_args();

        if ($this->oosql_del_multiFlag) {


            if ($numargs < $this->oosql_del_numargs) {
                $msg = 'Columns and passed data do not match! ' . $this->sql();
                throw new \Exception($msg, 9810, null);
            }


        }

        $from .= ' FROM ';

        $from .= $this->oosql_table;

        if ($numargs > 0) {
            $from .= ', ';

            $arg_list = func_get_args();

            for ($i = 0; $i < $numargs; $i++) {
                if ($i !== 0 && $numargs > $i) {
                    $from .= ', ';
                }

                if ($arg_list[$i] instanceof oosql) {

                    $arg_list[$i]->alias();
                    $fields = $arg_list[$i]->getFields($arg_list[$i]->getTableAlias());

                    $this->sql(',' . implode(', ', $fields));
                    $from .= $arg_list[$i]->getSql() . ' AS ' . $arg_list[$i]->getTableAlias();
                } else {
                    $from .= $arg_list[$i];
                }
            }
        }

        $this->sql($from);

        $this->oosql_fromFlag = false;

        return $this;
    }
206716
public function getDsn()
    {
        if ($this->checkParam()) {
            $sDsn = 'sqlite:';
            if ($this->getMemory() === true) {
                $sDsn .= ':memory:';
            } else {
                $sDsn .= $this->getDatabase();
            }
            return $sDsn;
        } else {
            return false;
        }
    }
1271446
public function count() {
        $sql    = $this->getSQL();
        $values = $this->values;
        if ($sql) {
            try {
                $ids = array_keys($this->datas);
                if ($this->batch && count($this->datas) > 1) {
                    unset($ids[0]);
                    $sqlValues = [];
                    foreach ($ids as $idx) {
                        $d       = $this->datas[ $idx ];
                        $vstring = [];
                        foreach ($d as $ff => $vv) {
                            if ($vv instanceof ImmutableValue) { // a immutable value
                                $vv->setDialect($this->dialect);
                                $vstring [] = $this->sanitize($vv->__toString());
                            } else if ($vv instanceof Query) { // a sub-select SQL as a value
                                $vv->setBindValues($values);
                                $vv->setDialect($this->dialect);
                                $vstring [] = '(' . $vv->__toString() . ')';
                            } else {
                                $vstring [] = $values->addValue($ff, $vv);
                            }
                        }
                        $sqlValues[] = '(' . implode(' , ', $vstring) . ')';
                    }
                    $this->sql = $sql = $sql . ',' . implode(' , ', $sqlValues);
                }

                $statement = $this->dialect->prepare($sql);

                foreach ($values as $value) {
                    list ($name, $val, $type) = $value;
                    if (!$statement->bindValue($name, $val, $type)) {
                        $this->errorSQL    = $sql;
                        $this->errorValues = $values->__toString();
                        $this->error       = 'can not bind the value ' . $val . '[' . $type . '] to the argument:' . $name;

                        return false;
                    }
                }

                $rst = $statement->execute();
                if ($rst) {
                    if ($this->keySet) {
                        $this->fillAutoIds();
                    } else {
                        $this->ids [] = $this->dialect->lastInsertId($this->keyField);
                    }

                    return $statement->rowCount();
                } else {
                    $this->dumpSQL($statement);
                }

                if ($statement) {
                    $statement->closeCursor();
                    $statement = null;
                }
            } catch (\PDOException $e) {
                $this->exception   = $e;
                $this->error       = $e->getMessage();
                $this->errorSQL    = $sql;
                $this->errorValues = $values->__toString();

                return false;
            }
        } else {
            $this->error       = 'Can not generate the insert SQL';
            $this->errorSQL    = '';
            $this->errorValues = $values->__toString();
        }

        return false;
    }
1051049
private boolean query()
		throws SQLException
	{
		statement = this.connection.createStatement();

		String query = "SELECT PrimaryKey, RevisionCounter,"
				+ " RevisionID, ArticleID, Timestamp, FullRevisionID "
				+ "FROM revisions";

		if (primaryKey > 0) {
			query += " WHERE PrimaryKey > " + primaryKey;
		}

		if (MAX_NUMBER_RESULTS > 0) {
			query += " LIMIT " + MAX_NUMBER_RESULTS;
		}

		result = statement.executeQuery(query);
		return result.next();
	}
394238
public function delete () : bool
	{
        $dbObject  = Database::getInstance();
		$sqlQuery  = "DELETE FROM ".static::$tableName." WHERE id=";
		$sqlQuery .= $dbObject->escapeValue($this->id)." LIMIT 1";
		$dbObject->query($sqlQuery);
		static::$affectedRows = $dbObject->affectedRows();
		return ($dbObject->affectedRows() == 1) ? TRUE : FALSE;
	}
1314778
public function executeQuery(): IResultSet {
        $temp = null;
        
        if (!$this->build()) {
            throw new \Exception('Error no se pudo construir la sentencia sql');
        }
        
        $temp = $this->conect->query($this->generate);
        $this->generate = "";
        
        if ($temp == null) {
            throw new \Exception('Error no se pudo encontrar nada en la base de datos');
        }
       
        return new ResultSetMYSQL($temp);
    }
964152
public function performQuery()
    {
        //change connection if provide
        if ($this->option('c')) {
            $this->schema->setConnection($this->option('c'));
            $this->schema->switchWrapper();
        }

        $rawQuery = $this->option('r');
        if (empty($rawQuery)) {
            $this->warn('Please provide raw sql query as string (in single/double quote)!');
            return false;
        }

         $result = $this->schema->rawQuery($rawQuery);
        if (!!$result) {
            (new Dumper)->dump($result);
        }
        $this->info('Query executed successfully!');
    }
1028937
public function errorInfo()
    {
        if (!$this->_stmt) {
            return false;
        }
        return array(
            substr($this->_stmt->sqlstate, 0, 5),
            $this->_stmt->errno,
            $this->_stmt->error,
        );
    }
223367
public function create()
    {
        $this->sql = new PhiberQueryWriter("create", [
            "table"  => $this->table,
            "fields" => $this->fields,
            "values" => $this->fieldsValues
        ]);

        if ($this->phiberConfig->verifyExecuteQueries()) {
            $stmt = $this->PDO->prepare($this->sql);

            for ($i = 0; $i < count($this->fields); $i++) {
                if ($this->fieldsValues[$i] != null) {
                    $stmt->bindValue($this->fields[$i], $this->fieldsValues[$i]);
                }
            }
            if ($stmt->execute()) {
                return $this->PDO->lastInsertId();
            }
        }

        return false;
    }
220627
function _query($sql,$inputarr=false)
	{
		$rez = $this->_connectionID->query($sql);
		if ($rez === false) {
			$this->_errorNo = $this->_connectionID->lastErrorCode();
		}
		// If no data was returned, we don't need to create a real recordset
		elseif ($rez->numColumns() == 0) {
			$rez->finalize();
			$rez = true;
		}

		return $rez;
	}
1342782
public function toSQL()
    {
        $sql = [];
        $this->params = [];

        $sql[] = 'SELECT';
        $sql[] = $this->columns->toSQL();
        $this->bind($this->columns->getParams());
        $sql[] = 'FROM ' . $this->table->getTableName();
        $sql[] = $this->where->toSQL();
        $this->bind($this->where->getParams());
        if ($this->group->has()) {
            $sql[] = $this->group->toSQL();
            $this->bind($this->order->getParams());
        }
        if ($this->having->has()) {
            $sql[] = $this->having->toSQL();
            $this->bind($this->having->getParams());
        }
        if ($this->order->has()) {
            $sql[] = $this->order->toSQL();
            $this->bind($this->order->getParams());
        }

        if ($this->limit !== null) {
            $sql[] = 'LIMIT ?';
            $this->params[] = $this->limit;
        }
        if ($this->offset !== null) {
            $sql[] = 'OFFSET ?';
            $this->params[] = $this->offset;
        }
        if ($this->lock_mode === Onikiri::LOCK_FOR_UPDATE) {
            $sql[] = 'FOR UPDATE';
        } elseif($this->lock_mode === Onikiri::LOCK_IN_SHARED) {
            $sql[] = 'LOCK IN SHARE MODE';
        }

        return join(' ', $sql);
    }
48014
private function getSQL()
    {
        $sql = $this->getTypeSQL()
                . $this->getWhereSQL()
                . $this->getOrderSQL()
                . $this->getLimitSQL()
                . $this->getOffsetSQL();
        return $sql;
    }
599575
public function exec(): bool
    {
        /* @var $sqlStmt \PDOStatement */
        $sqlStmt = $this->getConnection()->prepare($this->getQuery());

        if ($sqlStmt === false) {
            return $this->execFails($sqlStmt, ErrorType::CONNECTION_ERROR);
        }

        // Bind input
        foreach ($this->bindedValues as /* @var $i int */
                 $i => $bindedValue) {
            $type = $this->getPDOType($bindedValue);

            if ($type === false) {
                throw new \Exception('Invalid type of binded value at position ' . ($i + 1) . '.');
            }

            $bindParamsResult = $sqlStmt->bindValue($i + 1, $bindedValue, $type);

            if ($bindParamsResult === false) {
                return $this->execFails($sqlStmt, ErrorType::BINDING_ERROR);
            }
        }

        // Exec query
        $result = $sqlStmt->execute();

        if ($result == false) {
            return $this->execFails($sqlStmt, ErrorType::STATEMENT_ERROR);
        }

        $this->result = new MPDOResult($sqlStmt);

        $sqlStmt->closeCursor();

        return true;
    }