Obtém o PDO e Prepara a query
760828
private function connect()
    {
        $this->conn = parent::getConn();
        $this->update = $this->conn->prepare($this->update);
    }
237667
private function execute()
    {
        $this->connect();
        try {
            $this->update->execute(array_merge($this->dados, $this->places));
            $this->result = true;

            foreach ($this->resultsUpdates[0] as $col => $value) {
                if(!isset($this->dados[$col]))
                    $this->dados[$col] = $value;
            }

            $this->react = new React("update", str_replace(PRE, '', $this->tabela), $this->dados, $this->resultsUpdates);
        } catch (\PDOException $e) {
            $this->result = null;
            $this->erro = "<b>(Update) Erro ao Ler: ({$this->tabela})</b> {$e->getMessage()}";
        }

        parent::setDefault();
    }
582358
public function query($sql, $p = null){
        if ($p !== null){
            static $oldSql;
            static $stmt;
            if ($oldSql !== $sql || !$stmt){
                // for speedup
                $oldSql = $sql;
                $stmt = $this->conn->prepare($sql);

                if (!$stmt)
                    return false;
            }

            if (!is_array($p)){
                $p = array($p);
            }

            foreach($p as $k => $v){
                switch (true){
                case is_bool($v):
                    $typ = PDO::PARAM_BOOL;
                    break;
                case is_int($v):
                    $typ = PDO::PARAM_INT;
                    break;
                case is_null($v):
                    $typ = PDO::PARAM_NULL;
                    break;
                default:
                    $typ = PDO::PARAM_STR;
                }
                $stmt->bindValue($k + 1, $v, $typ);
            }
            $stmt->execute();

        }else{
            $stmt = $this->conn->query($sql);
            if (!$stmt)
                return false;
        }

        if ($stmt->errorCode() != '00000'){
            $errInfo = $stmt->errorInfo();
            trigger_error($sql . '['.$errInfo[0].':'.$errInfo[1].']'.$errInfo[2], E_USER_WARNING);
        }

        return $stmt;
    }
182885
public function execute(array $input_parameters = array())
	{
		$queryString = $this->queryString;
		
		if(count($input_parameters) > 0)
		{
			if(count($this->parameters) > 0 || count($this->parametersBound) > 0)
			{
				throw new LikePDOException("There is have parameters bound");
				return false;
			}
			else
			{
				foreach($input_parameters as $key => $param)
				{
					$value = is_int($param) ? intval($param) : $this->pdo->quote($param, LikePDO::PARAM_STR);
					
					if(is_int($key))
					{
						$position = strpos($queryString, "?");
						
						if(!strstr($queryString, "?"))
						{
							throw new LikePDOException("Statement: Too few parameters");
							return false;
						}
						
						$queryString = substr_replace($queryString, $value, $position, 1);
					}
					else
					{
						$queryString = str_replace($key, $value, $queryString);
					}
				}
			}
		}
		
		if(count($this->parametersBound) > 0)
		{
			foreach($this->parametersBound as $key => $param)
			{
				$value = $this->pdo->quote($param['variable'], $param['data_type']);
				
				if(is_int($key))
				{
					$position = strpos($queryString, "?");
					
					if(!strstr($queryString, "?"))
					{
						throw new LikePDOException("Statement: Too few parameters");
						return false;
					}
					
					$queryString = substr_replace($queryString, $value, $position, 1);
				}
				else
				{
					$queryString = str_replace($key, $value, $queryString);
				}
			}
		}
		
		if(count($this->parameters) > 0)
		{
			foreach($this->parameters as $key => $param)
			{
				$value = $this->pdo->quote($param['value'], $param['data_type']);
				
				if(is_int($key))
				{
					$position = strpos($queryString, "?");
					
					if(!strstr($queryString, "?"))
					{
						throw new LikePDOException("Statement: Too few parameters");
						return false;
					}
					
					$queryString = substr_replace($queryString, $value, $position, 1);
				}
				else
				{
					$queryString = str_replace($key, $value, $queryString);
				}
			}
		}
		
		$this->resource = $this->pdo->driver->query($queryString);
		$this->executed = true;
		$this->rowsAffected = $this->pdo->driver->getRowsAffected();
		$this->columnCount = $this->pdo->driver->getNumFields($this->resource);
		
		if(!$this->resource)
		{
			$this->failed = true;
			
			$this->errorCode = $this->pdo->errorCode();
			$this->errorInfo = $this->pdo->errorInfo();
			
			new LikePDOException("Failed to execute the query ".$this->queryString);
			
			return false;
		}
		
		return true;
	}
962021
public function query(string $q): \PDOStatement
    {
        try {
            $_SESSION['___QUERY_DEBUG___'][] = (string) $q;

            return parent::query($q);
        } catch (\Exception $e) {
            $message = 'Error in query: <b>' . $q . '<b/><br /><br />' . $e->getMessage();
        }
    }
1291815
protected function prepare_query() 
	{
		$this->query->where( $this->foreign_key, $this->local_model->{$this->local_key} )
			->limit( 1 );
	}
961702
function executeNonQuery($query) {

        try {
            $connection = $this->getConnection();

            if (!mysql_query($query, $connection)) {
                mysql_close($connection);
                throw new \Exception("SQL Error: " . mysql_error());
            }

            mysql_close($connection);
        } catch (\Exception $pEx) {
            throw new \Exception("Fallo al ejecutar la query: " . $query . $pEx->getMessage());
        }
    }
172714
public function select($query, $args = array(), $returnArray = true)
    {
        if($this->pdo) {

            if (!defined('GL_INSTALL') || !GL_INSTALL) {
                $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
            } else {
                $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
            }
            $stmt = $this->pdo->prepare($query);
            $result = $stmt->execute($args);
            //$list = array();
            if ($result) {
                if ($returnArray) {
                    return $stmt->fetchAll(\PDO::FETCH_ASSOC);
                }
                return true;
            } else {
                //            if($this->getLastError())
                throw new \Exception($query . "\n" . $this->getLastError());
            }
        } else {
            throw new \Exception("Error executing query: $query\nIt seems that the connection was not opened!");

        }
    }
670205
private function _queryPDO($sql, array $params = array())
    {
        try {
            $this->_queryId = self::$_linkId->prepare($sql);
            $i = 1;
            foreach ($params as $key => $val) {
                $type = $this->getPDOConstantType($val);
                $this->_queryId->bindValue($i, $val, $type);
                ++$i;
            }
            return $this->_queryId->execute();
        } catch (PDOException $e) {
            $this->_error = $e->getMessage();
            return false;
        }
    }
957452
public function query(string $sql, array $otpions = [])
    {
        $isAssociativeArray = function ($array) {  // return true si c'est un array associatif
            if (!is_array($array) || empty($array)) {
                return false;   
            }

            $keys = array_keys($array);
            
            return (array_keys($keys) !== $keys);
        };

        $this->prepare($sql);

        if ($otpions) {
            if ($isAssociativeArray($otpions)) {
                foreach ($otpions as $key => $value) {
                    $this->bind($key, $value, $this->bindDataType($value));
                }
            } else {
                $i = 1;
                foreach ($otpions as $value) {
                    $this->bind($i, $value, $this->bindDataType($value));
                    $i++;
                }
            }
        }

        $this->sqlQuery->execute();

        return $this->sqlQuery;
    }
340195
private function execute()
    {
        $this->Connect();
        try {
            $this->delete->execute($this->places);
            $this->result = true;
        } catch (\PDOException $e) {
            $this->result = null;
            $this->erro = "<b>Erro ao Deletar:</b> {$e->getMessage()}";
        }

        parent::setDefault();
    }
559639
public function prepare($query)
    {
        $this->connect();
        $options = [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL];
        $isObject = $query instanceof Query;
        if ($isObject && $query->isBufferedResultsEnabled() === false) {
            $options = [];
        }
        $statement = $this->_connection->prepare($isObject ? $query->sql() : $query, $options);

        return new SqlserverStatement($statement, $this);
    }
324546
public function debug()
    {
        $query = $this->pdo->prepare(<<<SQL
SELECT *
FROM robotstxt__cache1
WHERE base = :base;
SQL
        );
        $query->bindValue('base', $this->base, \PDO::PARAM_STR);
        $query->execute();
        return $query->rowCount() > 0 ? $query->fetch(\PDO::FETCH_ASSOC) : [];
    }
894159
private function execute()
    {
        $this->connect();
        try {
            $this->create->execute($this->dados);
            $this->result = $this->conn->lastInsertId();
            $this->react = new React("create", str_replace(PRE, '', $this->tabela), array_merge(["id" => $this->result], $this->dados));
        } catch (\PDOException $e) {
            $this->result = null;
            $this->erro = "<b>Erro ao cadastrar: ({$this->tabela})</b> {$e->getMessage()}";
        }

        parent::setDefault();
    }
1093303
function _query($sql,$inputarr=false)
	{
		$rs = @ldap_search( $this->_connectionID, $this->database, $sql );
		$this->_errorMsg = ($rs) ? '' : 'Search error on '.$sql.': '.ldap_error($this->_connectionID);
		return $rs;
	}
1267293
public function exec(): void
    {
        $this->queryExecuted = false;
        $sql = $this->getSQL();
        $adapter = $this->getAdapter();

        $adapter->prepare($sql);
        $bindings = $this->getBindings();

        try {
            foreach ($bindings->getBindings() as $bind) {
	            $adapter->getStatement()->bindValue($bind->getParameter(), $bind->getValue(), $bind->getType());
            }

	        $adapter->getStatement()->execute();

            Log::sql("{$this->adapter}>>>\n{$this->debug()}");
        } catch (PDOException $e) {
            // more descriptive error handling when query fails

            switch ($e->getCode()) {
                case 'HY093': // PDO miss match parameter count
                    //Log::debug("[{$e->getCode()}] Tried and failed to execute SQL query:\n{$sql}");
                    //Log::debug('BINDINGS', $bindings->getAsArray());
	                $exception = new QueryException("[{$e->getCode()}] Query bindings parameter miss match: {$e->getMessage()}", (int) $e->getCode(), $e);
                    break;

                default:
                    //Log::debug("[{$e->getCode()}] Tried and failed to execute SQL query:\n{$this->debug()}");
	                $exception = new QueryException("[{$e->getCode()}] Tried and failed to execute SQL query: {$e->getMessage()}", (int) $e->getCode(), $e);
                    break;
            }

            $exception->setAdapter($adapter->getConfigKey());
	        $exception->setSql($this->debug());
	        $exception->setBindings($bindings);
	        $exception->setWasPrepared(true);
            throw $exception;
        }

        $this->queryExecuted = true;
    }
667650
function execute() {
		try {

			// we need to bind in order
			if (empty($this->refactored_stmt)) {
				$index = [];

				$this->refactored_stmt = $this->query;

				# 
				# We need to sort by length to avoid replacing keys that are
				# prefixes of other keys, thereby invaliding the bigger keys
				#

				$keylengths = [];
				foreach (\array_keys($this->params) as $key) {
					$keylengths[$key] = strlen($key);
				}

				\asort($keylengths, SORT_NUMERIC);

				$keys = \array_keys(\array_reverse($keylengths, true));

				foreach ($keys as $key) {
					$position = \strpos($this->query, $key);
					if ($position == false) {
						throw new Panic("Tried to bind parameter $key but it's not present in statement.");
					}

					$this->refactored_stmt = \str_replace($key, '?', $this->refactored_stmt);

					$index[$key] = $position;
				}

				\asort($index, SORT_NUMERIC);

				$this->stmt = \mysqli_prepare($this->dbh, $this->refactored_stmt);

				if ( ! $this->stmt) {
					throw new Panic('Failed to prepare statement');
				}

				$bindings = '';
				$args = [ $this->stmt, null ];
				foreach (array_keys($index) as $key) {
					$bindings .= $this->params[$key][1];
					$args[] = & $this->params[$key][0];
				}

				$args[1] = $bindings;

				if ( ! empty($args[1])) {
					\call_user_func_array('mysqli_stmt_bind_param', $args);
				}
			}
			
			if ( ! \mysqli_stmt_execute($this->stmt)) {
				throw new Panic('Failed to execute statement');
			}

			#
			# to avoid complications with statements not getting closed before
			# new ones are executed we fetch the result set imediatly
			#

			$this->resultset = [];
			$result = \mysqli_stmt_get_result($this->stmt);
			while ($data = mysqli_fetch_assoc($result)) {
				$this->resultset[] = $data;
			}
		}
		catch (\Exception $exception) {
			$message = $exception->getMessage();
			$message .= "\n".$this->formatQuery($this->query);
			throw new Panic($message, 500, $exception);
		}

		return $this;
	}