public function query($queryString, array $queryValues = [])
    {
        if (!is_string($queryString) || empty($queryString)) {
            throw new \InvalidArgumentException(
                __METHOD__.': The specified query is not valid.'
            );
        }

        $this->connect();
        $this->resourceHandle = $this->dbConnection->prepare($queryString);

        try {
            // start transaction
            $this->dbConnection->beginTransaction();

            // execute the query and return a status
            $this->executionStatus = $this->resourceHandle->execute($queryValues ?: null);

            // get last inserted id if present
            $this->lastInsertedId = $this->dbConnection->lastInsertId();

            // finally execute the query
            $this->dbConnection->commit();
        } catch (\PDOException $ex) {
            // If an error occurs, execute rollback
            $this->dbConnection->rollBack();

            // Return execution status to false
            $this->executionStatus = false;
            $this->resourceHandle->closeCursor();

            throw new \RuntimeException(
                __METHOD__.": {$ex->getMessage()}\nqueryString: {$queryString}"
            );
        }

        return $this->resourceHandle;
    }
public function query($queryString, array $queryValues = [])
    {
        if (!is_string($queryString) || empty($queryString)) {
            throw new \InvalidArgumentException(
                __METHOD__.': The specified query is not valid.'
            );
        }

        $this->connect();
        $this->resourceHandle = $this->dbConnection->prepare($queryString);

        try {
            // start transaction
            $this->dbConnection->beginTransaction();

            // execute the query and return a status
            $this->executionStatus = $this->resourceHandle->execute($queryValues ?: null);

            // get last inserted id if present
            $this->lastInsertedId = $this->dbConnection->lastInsertId();

            // finally execute the query
            $this->dbConnection->commit();
        } catch (\PDOException $ex) {
            // If an error occurs, execute rollback
            $this->dbConnection->rollBack();

            // Return execution status to false
            $this->executionStatus = false;
            $this->resourceHandle->closeCursor();

            throw new \RuntimeException(
                __METHOD__.": {$ex->getMessage()}\nqueryString: {$queryString}"
            );
        }

        return $this->resourceHandle;
    }
public function query ( $ queryString , array $ queryValues = [ ] ) { if ( ! is_string ( $ queryString ) || empty ( $ queryString ) ) { throw new \ InvalidArgumentException ( __METHOD__ . ': The specified query is not valid.' ) ; } $ this -> connect ( ) ; $ this -> resourceHandle = $ this -> dbConnection -> prepare ( $ queryString ) ; try { // start transaction $ this -> dbConnection -> beginTransaction ( ) ; // execute the query and return a status $ this -> executionStatus = $ this -> resourceHandle -> execute ( $ queryValues ? : null ) ; // get last inserted id if present $ this -> lastInsertedId = $ this -> dbConnection -> lastInsertId ( ) ; // finally execute the query $ this -> dbConnection -> commit ( ) ; } catch ( \ PDOException $ ex ) { // If an error occurs, execute rollback $ this -> dbConnection -> rollBack ( ) ; // Return execution status to false $ this -> executionStatus = false ; $ this -> resourceHandle -> closeCursor ( ) ; throw new \ RuntimeException ( __METHOD__ . ": {$ex->getMessage()}\nqueryString: {$queryString}" ) ; } return $ this -> resourceHandle ; }
Execute a query or a prepared statement with a params array values.

@param string $queryString
@param array $queryValues in format [:placeholder => 'value']

@return mixed
Execute a query or a prepared statement with a params array values .