src/Native5/Core/Database/DB.php
protected function exec(\PDOStatement $statement, $type = self::SELECT) {
        // Execute
        try {
            $statement->execute();
        } catch (\PDOException $pe) {
            $statement->closeCursor();
            throw new \Exception("Error while executing query:: sql: ".$statement->queryString.PHP_EOL."Message: ".$pe->getMessage());
        }

        // Process Result based on the query type
        if ($type == self::SELECT) {
            $result = array();
            foreach($statement as $row) {
                $result[] = $row;
            }
        } else if ($type == self::INSERT) {
            // No need to check connection here
            $result = (int)$this->getConnection(false)->lastInsertId();
        } else {
            $result = true;
        }

        $statement->closeCursor();

        return $result;
    }
protected function exec(\PDOStatement $statement, $type = self::SELECT) {
        // Execute
        try {
            $statement->execute();
        } catch (\PDOException $pe) {
            $statement->closeCursor();
            throw new \Exception("Error while executing query:: sql: ".$statement->queryString.PHP_EOL."Message: ".$pe->getMessage());
        }

        // Process Result based on the query type
        if ($type == self::SELECT) {
            $result = array();
            foreach($statement as $row) {
                $result[] = $row;
            }
        } else if ($type == self::INSERT) {
            // No need to check connection here
            $result = (int)$this->getConnection(false)->lastInsertId();
        } else {
            $result = true;
        }

        $statement->closeCursor();

        return $result;
    }
protected function exec ( \ PDOStatement $ statement , $ type = self :: SELECT ) { // Execute try { $ statement -> execute ( ) ; } catch ( \ PDOException $ pe ) { $ statement -> closeCursor ( ) ; throw new \ Exception ( "Error while executing query:: sql: " . $ statement -> queryString . PHP_EOL . "Message: " . $ pe -> getMessage ( ) ) ; } // Process Result based on the query type if ( $ type == self :: SELECT ) { $ result = array ( ) ; foreach ( $ statement as $ row ) { $ result [ ] = $ row ; } } else if ( $ type == self :: INSERT ) { // No need to check connection here $ result = ( int ) $ this -> getConnection ( false ) -> lastInsertId ( ) ; } else { $ result = true ; } $ statement -> closeCursor ( ) ; return $ result ; }
exec Execute prepared statement on this database, reconnects to DB if connection does not exist

@param object $query PDO prepared statement to execute
@param mixed $type Type of database query - refer class constants
@param boolean $reconnect true if should reconnect to DB on a connection failure, false otherwise
@access protected
@return array|int|boolean SELECT - array of all selected rows as associative arrays on success, throws exception otherwise
INSERT- Database ID for inserted row, throws exception otherwise
UPDATE | DELETE- true on success, throws exception otherwise
@throws Exception if could not execute the query successfuly
exec Execute prepared statement on this database reconnects to DB if connection does not exist