* Represents a prepared statements based upon pdo statements.
*
* @author Marcel Werk
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.database.statement
* @category Community Framework
+ *
+ * @method boolean closeCursor()
+ * @method mixed fetch($fetch_style, $cursor_orientation = \PDO::FETCH_ORI_NEXT, $cursor_offset = 0)
+ * @method mixed fetchColumn($column_number = 0)
*/
class PreparedStatement {
/**
* database object
- * @var \wcf\system\database\Database
+ * @var Database
*/
protected $database = null;
* SQL query parameters
* @var array
*/
- protected $parameters = array();
+ protected $parameters = [];
/**
* pdo statement object
/**
* Creates a new PreparedStatement object.
*
- * @param \wcf\system\database\Database $database
- * @param \PDOStatement $pdoStatement
- * @param string $query SQL query
+ * @param Database $database
+ * @param \PDOStatement $pdoStatement
+ * @param string $query SQL query
*/
public function __construct(Database $database, \PDOStatement $pdoStatement, $query = '') {
$this->database = $database;
}
try {
- return call_user_func_array(array($this->pdoStatement, $name), $arguments);
+ return call_user_func_array([$this->pdoStatement, $name], $arguments);
}
catch (\PDOException $e) {
throw new DatabaseQueryException("Could call '".$name."' on '".$this->query."'", $e);
* @param array $parameters
* @throws DatabaseQueryExecutionException
*/
- public function execute(array $parameters = array()) {
+ public function execute(array $parameters = []) {
$this->parameters = $parameters;
$this->database->incrementQueryCount();
* @return DatabaseObject[]
*/
public function fetchObjects($className) {
- $objects = array();
+ $objects = [];
while ($object = $this->fetchObject($className)) {
$objects[] = $object;
}