********************************\
Executes an action to the database
@param  string $query  => the database query
@param  array  $params => (the query parameters)
@return mixed          => the verity value
190537
public function action(string $query, array $params = [])
    {
        // Prepares the query, then stores it
        $PDOStatement = $this->pdo->prepare($query);

        // Executes the query, then returns the boolean value
        return $PDOStatement->execute($params);
    }
670654
public function sendQueryWithParameters($query, array $parameters = [])
    {
        $res = pg_send_query_params(
            $this->getHandler(),
            $query,
            $parameters
        );

        try {
            return $this
                ->testQuery($res, $query)
                ->getQueryResult($query)
                ;
        } catch (SqlException $e) {
            throw $e->setQueryParameters($parameters);
        }
    }
911331
public static function setParams($query, array $params = []) {
        Str::assert($query, 'query');

        return array_reduce($params, function($query, $param) {
            $param = self::getStringRepresentation($param);

            return strpos($query, '?') ? substr_replace($query, $param, strpos($query, '?'), strlen('?')) : $query;
        }, $query);
    }
1160023
public function query($query, array $params = [])
    {
        if (!$this->nextQueryIsolationLevel) {
            return $this->retryQuery($query, $params);
        }

        [$oldLevel] = $this->setIsolationLevel($this->nextQueryIsolationLevel);
        $result = $this->retryQuery($query, $params);
        $this->setIsolationLevel($oldLevel);

        return $result;
    }
1184442
public function execute(string $query, array $params = []) : object
    {
        list($query, $params) = $this->expandParamArray($query, $params);

        if (!$this->pdo) {
            $this->createException("Did you forget to connect to the database?", $query, $params);
        }

        $this->stmt = $this->pdo->prepare($query);
        if (!$this->stmt) {
            $this->pdoException($query, $params);
        }

        if ($this->options["verbose"]) {
            echo $query . "\n";
            print_r($params);
        }

        $res = $this->stmt->execute($params);
        if (!$res) {
            $this->statementException($query, $params);
        }

        return $this;
    }
1277769
public function execute($query = null, array $params = []) : object
    {
        // When using one argument and its array, assume its $params
        if (is_array($query)) {
            $params = $query;
            $query = null;
        }

        if (!$query) {
            $query = $this->getSQL();
        }

        return parent::execute($query, $params);
    }
974874
public static function dump(string $query, array $params = [])
	{
		[$query, $params] = Doctrine\DBAL\SQLParserUtils::expandListParameters($query, $params, []);

		$parts = explode('?', $query);

		$output = [];
		while ($parts && $params) {
			$output[] = array_shift($parts);
			$output[] = self::formatParameter(array_shift($params));
		}

		return self::highlightQuery(implode('', array_merge($output, $parts ? : [], $params ? : [])));
	}
726548
public function execute($params = array(), $request = array()) {
        //$passableParams = $this->httpRequest->getParameters();
        //remove the uri
        // array_shift($passableParams);

        $this->getQueryBuilder()->where($params);
        $query = '';
        if ($this->entity instanceof AbstractI18nEntity) {
            $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ITEM_QUERY, QueryBuilder::PARENT_AND_CHILD);
        } else {
            $query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::GET_ITEM_QUERY);
        }

        $firstResult = $this->query($query);
        $entityName = get_class($this->entity);

        if (is_array($firstResult) && count($firstResult) > 0) {

            $this->loadI18nValues($firstResult, $params);

            $this->loadChildTableParams($firstResult, $params);

            $this->loadOneToOneJoinTables($firstResult);

            $this->loadOneToManyJoinTables($firstResult, $params);


        }

        return array($entityName => is_array($firstResult) ? current($firstResult) : array());
    }
1080838
final public static function getObjectsByQuery($query, $params=[]) {
		
		$app	= Application::getInstance();
		$db		= Database::getInstance();
		$class	= get_called_class();

		// run query
		$db->setQuery($query);
		$list = $db->loadObjectList($params);
		
		// array that returns and custom binds
		$objects = [];
		$customBinds = [];
		
		if (is_array($list) and isset($list[0])) {
			
			$binds = $class::getBinds();
			
			// get object properties from query
			$fields  = get_object_vars($list[0]);

			// search for custom field names
			foreach ($fields as $field=>$value) {
				if (!array_search($field, $binds)) {
					$customBinds[Utilities::getCamelCase($field)] = $field;
				}
			}

			// build each object
			foreach ($list as $row) {
				
				$object = new $class($row);

				// populate custom properties
				foreach ($customBinds as $customProp=>$customField) {
					$object->$customProp = $row->$customField;
				}
				
				// turn on loaded-from-db flag
				$object->loadedFromDb = TRUE;

				$objects[] = $object;
				
			}
			
		}
		
		$app->logEvent('Loaded ' . count($objects) . ' ' . $class . ' objects with custom fields ' . implode(',', $customBinds));
		
		return $objects;
		
	}
1120140
protected function query($query, ...$params)
    {
        $saveParams = array_map([$this, 'quote'], $params);

        $baseSql = str_replace('{table}', $this->table, $query);
        $sql = vsprintf($baseSql, $saveParams);

        $ret = $this->server->query($sql);

        if ($ret === false) {
            trigger_error($this->server->error . " $sql", E_USER_NOTICE);
        }

        return $ret;
    }
730174
protected function executePreparedStatement($query, $params)
        {
            $res = odbc_prepare($this->_lnk, $query);
            if(!$res) {
                $error = odbc_errormsg($this->_lnk);
                $this->log('Prepare failed: ' . $error);
                throw new Exception('Preparing query failed ' . $error, self::PREPARE_FAILED);
            }
            $res = odbc_execute($res, $params);
            if(!$res) {
                $error = odbc_errormsg($this->_lnk);
                $this->log('Prepared query execution failed: ' . $error);
                throw new Exception('Executing prepared query failed ' . $error, self::QUERY_FAILED);
            }
            return $res;
        }
1058191
protected function _fetchAll($query, $params)
    {
        $db = $this->db;
        $sth = $db->prepare($query);
        foreach ($params as $key => $val) {
            if (is_int($val)) {
                $sth->bindValue("$key", $val, $db::PARAM_INT);
            } else {
                $sth->bindValue("$key", $val);
            }
        }
        $sth->execute();
        return $sth->fetchAll($db::FETCH_ASSOC);
    }
376431
public function execute(string $query, array $parameters = []): int
    {
        return $this->statement($query, $parameters)->rowCount();
    }
349281
public function select($query, array $params = [], $fetchMode = null)
    {
        // Execute query
        $stmt = $this->connection->prepare($query);
        $stmt->execute($params);
        if ($fetchMode !== null) {
            $stmt->setFetchMode($fetchMode);
        }
        return $stmt->fetchAll();
    }
1177010
public function query($sql, array $params = array())
    {
        //$helper = $this->getHelper();
        $con = $this->establishConnection();
        $sth = $con->prepare($sql, array(Connection::ATTR_CURSOR => Connection::CURSOR_SCROLL));

        // bind params
        foreach($params as $key => $value){
            $type = Connection::PARAM_STR;
            if ( is_null($value) ) {
                $type = Connection::PARAM_NULL;
            } elseif ( is_int($value) ) {
                $type = Connection::PARAM_INT;
            } elseif ( is_bool($value) ) {
                $type = Connection::PARAM_BOOL;
            } elseif ( is_resource($value) ) {
                $type = Connection::PARAM_LOB;
            }
            if ( is_int($key) ) {
                $sth->bindValue($key + 1, $value, $type);
            } else {
                $sth->bindValue($key, $value, $type);
            }
        }

        $result = $sth->execute();
        return $sth;
    }
940666
protected function execute($query)
    {
        $query->execute($this->bindings);
        
        $this->bindings = [];
        $this->wheres   = [];

        return $query;
    }
138225
public function statement( $query, $params = array() )
	{
		// we alway prepare the query even if we dont have parameters
		$sth = $this->driver()->connection()->prepare( $query );
		
		// because we set pdo the throw exception on db errors
		// we catch them here to throw our own exception.
		try 
		{
			$sth->execute( $params );
		}
		catch ( \PDOException $e ) 
		{
			throw new Exception( "DB\\Handler - PDOException: {$e->getMessage()} \n Query: {$query}" );
		}
		
		// In development we alway log the query into an array.
		if ( \ClanCats::in_development() ) 
		{	
			$keys = array();
			
			foreach ( $params as $key => $value ) 
			{
				if ( is_string( $key ) ) 
				{
					$keys[] = '/:'.$key.'/';
				} else {
					$keys[] = '/[?]/';
				}
			}
			
			static::$_query_log[] = preg_replace( $keys, $params, $query, 1 );
		}
		
		return $sth;
	}