diff --git a/src/Propel/Generator/Reverse/OracleSchemaParser.php b/src/Propel/Generator/Reverse/OracleSchemaParser.php index 8be1cce6d9..d780426b6f 100644 --- a/src/Propel/Generator/Reverse/OracleSchemaParser.php +++ b/src/Propel/Generator/Reverse/OracleSchemaParser.php @@ -18,7 +18,6 @@ use Propel\Generator\Model\Index; use Propel\Generator\Model\PropelTypes; use Propel\Generator\Model\Table; -use Propel\Runtime\Connection\StatementInterface; /** * Oracle database schema parser. @@ -229,11 +228,11 @@ protected function addForeignKeys(Table $table) // local store to avoid duplicates $foreignKeys = []; - /* @var StatementInterface $stmt */ + /* @var \PDOStatement $stmt */ $stmt = $this->dbh->query("SELECT CONSTRAINT_NAME, DELETE_RULE, R_CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'R' AND TABLE_NAME = '" . $table->getName(). "'"); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { // Local reference - /* @var StatementInterface $stmt2 */ + /* @var \PDOStatement $stmt2 */ $stmt2 = $this->dbh->query("SELECT COLUMN_NAME FROM USER_CONS_COLUMNS WHERE CONSTRAINT_NAME = '".$row['CONSTRAINT_NAME']."' AND TABLE_NAME = '" . $table->getName(). "'"); $localReferenceInfo = $stmt2->fetch(\PDO::FETCH_ASSOC); diff --git a/src/Propel/Generator/Util/QuickBuilder.php b/src/Propel/Generator/Util/QuickBuilder.php index 134ef62b9b..d8a98f55a2 100644 --- a/src/Propel/Generator/Util/QuickBuilder.php +++ b/src/Propel/Generator/Util/QuickBuilder.php @@ -24,7 +24,6 @@ use Propel\Runtime\Connection\PdoConnection; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\ConnectionWrapper; -use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Propel; class QuickBuilder @@ -228,7 +227,7 @@ public function buildSQL(ConnectionInterface $con) } try { $stmt = $con->prepare($statement); - if ($stmt instanceof StatementInterface) { + if ($stmt instanceof \PDOStatement) { // only execute if has no error $stmt->execute(); } diff --git a/src/Propel/Generator/Util/SqlParser.php b/src/Propel/Generator/Util/SqlParser.php index 0f12595fea..1a2b75a259 100644 --- a/src/Propel/Generator/Util/SqlParser.php +++ b/src/Propel/Generator/Util/SqlParser.php @@ -11,7 +11,6 @@ namespace Propel\Generator\Util; use \Propel\Runtime\Connection\ConnectionInterface; -use \Propel\Runtime\Connection\StatementInterface; /** * Service class for parsing a large SQL string into an array of SQL statements @@ -93,7 +92,7 @@ protected static function executeStatements($statements, ConnectionInterface $co foreach ($statements as $statement) { $stmt = $connection->prepare($statement); - if ($stmt instanceof StatementInterface) { + if ($stmt instanceof \PDOStatement) { // only execute if has no error $stmt->execute(); $executed++; diff --git a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php index ccfddaf510..b604eac022 100644 --- a/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/MysqlAdapter.php @@ -12,7 +12,6 @@ use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Map\ColumnMap; /** @@ -143,15 +142,15 @@ public function random($seed = null) /** * @see AdapterInterface::bindValue() * - * @param StatementInterface $stmt - * @param string $parameter - * @param mixed $value - * @param ColumnMap $cMap - * @param null|integer $position + * @param \PDOStatement $stmt + * @param string $parameter + * @param mixed $value + * @param ColumnMap $cMap + * @param null|integer $position * * @return boolean */ - public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { $pdoType = $cMap->getPdoType(); // FIXME - This is a temporary hack to get around apparent bugs w/ PDO+MYSQL diff --git a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php index ee11c63540..9bffc3e34a 100644 --- a/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/OracleAdapter.php @@ -14,7 +14,6 @@ use Propel\Runtime\Adapter\AdapterInterface; use Propel\Runtime\Adapter\SqlAdapterInterface; use Propel\Runtime\Connection\ConnectionInterface; -use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\ColumnMap; use Propel\Generator\Model\PropelTypes; @@ -207,15 +206,15 @@ public function turnSelectColumnsToAliases(Criteria $criteria) /** * @see AdapterInterface::bindValue() * - * @param StatementInterface $stmt - * @param string $parameter - * @param mixed $value - * @param ColumnMap $cMap - * @param null|integer $position + * @param \PDOStatement $stmt + * @param string $parameter + * @param mixed $value + * @param ColumnMap $cMap + * @param null|integer $position * * @return boolean */ - public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { if (PropelTypes::CLOB_EMU === $cMap->getType()) { return $stmt->bindParam(':p'.$position, $value, $cMap->getPdoType(), strlen($value)); diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php index 2a245433cf..cdac51083a 100644 --- a/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php +++ b/src/Propel/Runtime/Adapter/Pdo/PdoAdapter.php @@ -14,7 +14,6 @@ use Propel\Runtime\Adapter\Exception\AdapterException; use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\PdoConnection; -use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Exception\InvalidArgumentException; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; @@ -552,11 +551,11 @@ public function turnSelectColumnsToAliases(Criteria $criteria) * $stmt->execute(); * * - * @param StatementInterface $stmt - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param DatabaseMap $dbMap + * @param \PDOStatement $stmt + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param DatabaseMap $dbMap */ - public function bindValues(StatementInterface $stmt, array $params, DatabaseMap $dbMap) + public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMap) { $position = 0; foreach ($params as $param) { @@ -582,15 +581,15 @@ public function bindValues(StatementInterface $stmt, array $params, DatabaseMap * Binds a value to a positioned parameter in a statement, * given a ColumnMap object to infer the binding type. * - * @param StatementInterface $stmt The statement to bind - * @param string $parameter Parameter identifier - * @param mixed $value The value to bind - * @param ColumnMap $cMap The ColumnMap of the column to bind - * @param null|integer $position The position of the parameter to bind + * @param \PDOStatement $stmt The statement to bind + * @param string $parameter Parameter identifier + * @param mixed $value The value to bind + * @param ColumnMap $cMap The ColumnMap of the column to bind + * @param null|integer $position The position of the parameter to bind * * @return boolean */ - public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null) + public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null) { if ($cMap->isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); diff --git a/src/Propel/Runtime/Adapter/Pdo/PdoStatement.php b/src/Propel/Runtime/Adapter/Pdo/PdoStatement.php deleted file mode 100644 index 29ba1e9ffa..0000000000 --- a/src/Propel/Runtime/Adapter/Pdo/PdoStatement.php +++ /dev/null @@ -1,101 +0,0 @@ -isTemporal()) { $value = $this->formatTemporalValue($value, $cMap); diff --git a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php index e97a250d5c..de7d3e9211 100644 --- a/src/Propel/Runtime/Adapter/SqlAdapterInterface.php +++ b/src/Propel/Runtime/Adapter/SqlAdapterInterface.php @@ -10,7 +10,6 @@ namespace Propel\Runtime\Adapter; -use Propel\Runtime\Connection\StatementInterface; use Propel\Runtime\Map\ColumnMap; use Propel\Runtime\Map\DatabaseMap; use Propel\Runtime\ActiveQuery\Criteria; @@ -113,23 +112,23 @@ public function turnSelectColumnsToAliases(Criteria $criteria); * $stmt->execute(); * * - * @param StatementInterface $stmt - * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) - * @param DatabaseMap $dbMap + * @param \PDOStatement $stmt + * @param array $params array('column' => ..., 'table' => ..., 'value' => ...) + * @param DatabaseMap $dbMap */ - public function bindValues(StatementInterface $stmt, array $params, DatabaseMap $dbMap); + public function bindValues(\PDOStatement $stmt, array $params, DatabaseMap $dbMap); /** * Binds a value to a positioned parameter in a statement, * given a ColumnMap object to infer the binding type. * - * @param StatementInterface $stmt The statement to bind - * @param string $parameter Parameter identifier - * @param mixed $value The value to bind - * @param ColumnMap $cMap The ColumnMap of the column to bind - * @param null|integer $position The position of the parameter to bind + * @param \PDOStatement $stmt The statement to bind + * @param string $parameter Parameter identifier + * @param mixed $value The value to bind + * @param ColumnMap $cMap The ColumnMap of the column to bind + * @param null|integer $position The position of the parameter to bind * * @return boolean */ - public function bindValue(StatementInterface $stmt, $parameter, $value, ColumnMap $cMap, $position = null); + public function bindValue(\PDOStatement $stmt, $parameter, $value, ColumnMap $cMap, $position = null); } diff --git a/src/Propel/Runtime/Connection/ConnectionInterface.php b/src/Propel/Runtime/Connection/ConnectionInterface.php index b35865744c..210a4921de 100644 --- a/src/Propel/Runtime/Connection/ConnectionInterface.php +++ b/src/Propel/Runtime/Connection/ConnectionInterface.php @@ -165,8 +165,9 @@ public function exec($statement); * database server. * @param array $driver_options * - * @return \Propel\Runtime\Connection\StatementInterface|bool A Statement object if the database server - * successfully prepares, FALSE otherwise. + * @return \PDOStatement|bool A Statement object if the database server + * successfully prepares, FALSE otherwise. + * @throws \Propel\Runtime\Connection\Exception\ConnectionException depending on error handling. */ public function prepare($statement, $driver_options = null); diff --git a/src/Propel/Runtime/Connection/ConnectionWrapper.php b/src/Propel/Runtime/Connection/ConnectionWrapper.php index ca45b98064..4eb7a78db0 100644 --- a/src/Propel/Runtime/Connection/ConnectionWrapper.php +++ b/src/Propel/Runtime/Connection/ConnectionWrapper.php @@ -370,7 +370,7 @@ public function setAttribute($attribute, $value) * @param array $driver_options One $array or more key => value pairs to set attribute values * for the PDOStatement object that this method returns. * - * @return StatementInterface + * @return \PDOStatement */ public function prepare($statement, $driver_options = null) { @@ -424,7 +424,7 @@ public function exec($sql) * @param string $statement The SQL statement to prepare and execute. * Data inside the query should be properly escaped. * - * @return StatementInterface + * @return \PDOStatement */ public function query($statement) { diff --git a/src/Propel/Runtime/Connection/PdoConnection.php b/src/Propel/Runtime/Connection/PdoConnection.php index f883097550..b499d8c56d 100644 --- a/src/Propel/Runtime/Connection/PdoConnection.php +++ b/src/Propel/Runtime/Connection/PdoConnection.php @@ -14,7 +14,7 @@ use Propel\Runtime\DataFetcher\PDODataFetcher; /** - * PDO extension that implements ConnectionInterface and builds statements implementing StatementInterface. + * PDO extension that implements ConnectionInterface and builds \PDOStatement statements. */ class PdoConnection extends \PDO implements ConnectionInterface { @@ -58,7 +58,6 @@ public function __construct($dsn, $user = null, $password = null, array $options parent::__construct($dsn, $user, $password, $pdoOptions); - $this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, ['\Propel\Runtime\Adapter\Pdo\PdoStatement', []]); $this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); } @@ -146,7 +145,7 @@ public function lastInsertId($name = null) * * @param string $statement * @param array $driver_options - * @return bool|\PDOStatement|StatementInterface|void + * @return bool|\PDOStatement|void */ public function prepare($statement, $driver_options = null) { diff --git a/src/Propel/Runtime/Connection/StatementInterface.php b/src/Propel/Runtime/Connection/StatementInterface.php deleted file mode 100644 index 89aa1bad7c..0000000000 --- a/src/Propel/Runtime/Connection/StatementInterface.php +++ /dev/null @@ -1,174 +0,0 @@ -bindValue(), - * the variable is bound as a reference and will only be evaluated at the time - * that PDOStatement->execute() is called. - * - * Most parameters are input parameters, that is, parameters that are - * used in a read-only fashion to build up the query. Some drivers support the invocation - * of stored procedures that return data as output parameters, and some also as input/output - * parameters that both send in data and are updated to receive it. - * - * @param mixed $column Parameter identifier. For a prepared statement using named placeholders, - * this will be a parameter name of the form :name. For a prepared statement - * using question mark placeholders, this will be the 1-indexed position of the parameter - * - * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. - * - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return - * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the - * PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter. - * @return boolean Returns TRUE on success or FALSE on failure. - */ - public function bindParam($column, &$variable, $type = null); - - /** - * Binds a value to a parameter. - * - * Binds a value to a corresponding named or question mark placeholder - * in the SQL statement that was used to prepare the statement. - * - * @param mixed $param Parameter identifier. For a prepared statement using named placeholders, - * this will be a parameter name of the form :name. For a prepared statement - * using question mark placeholders, this will be the 1-indexed position of the parameter - * - * @param mixed $value The value to bind to the parameter. - * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. - * - * @return boolean Returns TRUE on success or FALSE on failure. - */ - public function bindValue($param, $value, $type = null); - - /** - * Closes the cursor, enabling the statement to be executed again. - * - * closeCursor() frees up the connection to the server so that other SQL - * statements may be issued, but leaves the statement in a state that enables - * it to be executed again. - * - * This method is useful for database drivers that do not support executing - * a PDOStatement object when a previously executed PDOStatement object still - * has unfetched rows. If your database driver suffers from this limitation, - * the problem may manifest itself in an out-of-sequence error. - * - * @return boolean Returns TRUE on success or FALSE on failure. - */ - public function closeCursor(); - - /** - * Returns the number of columns in the result set. - * - * Use columnCount() to return the number of columns in the result set - * represented by the Statement object. - * - * If the Statement object was returned from PDO::query(), the column count - * is immediately available. - * - * If the Statement object was returned from PDO::prepare(), an accurate - * column count will not be available until you invoke Statement::execute(). - * Returns the number of columns in the result set - * - * @return integer Returns the number of columns in the result set represented - * by the PDOStatement object. If there is no result set, - * this method should return 0. - */ - public function columnCount(); - - /** - * Executes a prepared statement. - * - * If the prepared statement included parameter markers, you must either: - * - call PDOStatement->bindParam() to bind PHP variables to the parameter markers: - * bound variables pass their value as input and receive the output value, - * if any, of their associated parameter markers - * - or pass an array of input-only parameter values - * - * - * @param array $parameters An array of values with as many elements as there are - * bound parameters in the SQL statement being executed. - * @return boolean Returns TRUE on success or FALSE on failure. - */ - public function execute($parameters = null); - - /** - * Fetches the next row from a result set. - * - * Fetches a row from a result set associated with a Statement object. - * The fetch_style parameter determines how the Connection returns the row. - * - * @param integer $fetchStyle Controls how the next row will be returned to the caller. - * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor, - * This value determines which row will be returned to the caller. - * @param integer $cursorOffset For a PDOStatement object representing a - * scrollable cursor for which the cursor_orientation - * parameter is set to PDO::FETCH_ORI_ABS, this value - * specifies the absolute number of the row in the - * result set that shall be fetched. - * - * For a PDOStatement object representing a - * scrollable cursor for which the cursor_orientation - * parameter is set to PDO::FETCH_ORI_REL, this value - * specifies the row to fetch relative to the cursor - * position before PDOStatement::fetch() was called. - * - * @return mixed - */ - public function fetch($fetchStyle = 4); - - /** - * Returns an array containing all of the result set rows. - * - * @param integer $fetchStyle Controls the contents of the returned array as documented in fetch() - * @return array - */ - public function fetchAll($fetchStyle = 4); - - /** - * Returns a single column from the next row of a result set. - * - * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no - * value is supplied, PDOStatement->fetchColumn() - * fetches the first column. - * - * @return string A single column in the next row of a result set. - */ - public function fetchColumn($columnIndex = 0); - - /** - * Returns the number of rows affected by the last SQL statement - * - * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement - * executed by the corresponding Statement object. - * - * If the last SQL statement executed by the associated Statement object was a SELECT statement, - * some databases may return the number of rows returned by that statement. However, - * this behaviour is not guaranteed for all databases and should not be - * relied on for portable applications. - * - * @return integer The number of rows. - */ - public function rowCount(); -} diff --git a/src/Propel/Runtime/Connection/StatementWrapper.php b/src/Propel/Runtime/Connection/StatementWrapper.php index 2eb2a7f196..64b97fed3d 100644 --- a/src/Propel/Runtime/Connection/StatementWrapper.php +++ b/src/Propel/Runtime/Connection/StatementWrapper.php @@ -14,12 +14,12 @@ * Wraps a Statement class, providing logging. * */ -class StatementWrapper implements StatementInterface, \IteratorAggregate +class StatementWrapper extends \PDOStatement implements \IteratorAggregate { /** * The wrapped statement class - * @var StatementInterface + * @var \PDOStatement */ protected $statement; @@ -233,7 +233,7 @@ public function getExecutedQueryString($input_parameters = null) * * @return mixed */ - public function fetch($fetchStyle = 4) + public function fetch($fetchStyle = \PDO::FETCH_BOTH, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { return $this->statement->fetch($fetchStyle); } @@ -245,7 +245,7 @@ public function fetch($fetchStyle = 4) * * @return array */ - public function fetchAll($fetchStyle = 4) + public function fetchAll($fetchStyle = \PDO::FETCH_BOTH, $fetchArgument = null, $ctorArgs = []) { return $this->statement->fetchAll($fetchStyle); } @@ -301,7 +301,7 @@ public function getConnection() } /** - * @return StatementInterface + * @return \PDOStatement */ public function getStatement() { @@ -309,9 +309,9 @@ public function getStatement() } /** - * @param StatementInterface $statement + * @param \PDOStatement $statement */ - public function setStatement(StatementInterface $statement) + public function setStatement(\PDOStatement $statement) { $this->statement = $statement; } diff --git a/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php b/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php index 2592112103..6288a590c4 100644 --- a/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php +++ b/tests/Propel/Tests/Runtime/Connection/PropelPDOTest.php @@ -360,7 +360,7 @@ public function testUseDebug() $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME); $con->useDebug(false); $stmtClass = $con->getAttribute(PDO::ATTR_STATEMENT_CLASS); - $expectedClass = (defined('HHVM_VERSION') ? '\\' : '') . 'Propel\Runtime\Adapter\Pdo\PdoStatement'; + $expectedClass = defined('HHVM_VERSION') ? '\PdoStatement' : 'PDOStatement'; $this->assertEquals($expectedClass, $stmtClass[0], 'Statement is Propel Statement when debug is false'); $con->useDebug(true);