* @package Mammut\DB\Adapter\PDO */ class Statement extends \Mammut\DB\Statement { use PDOFetchable; public function __construct(PDO $database, \PDOStatement $statement) { $this->db = $database; $this->stmt = $statement; $this->executed = false; } public function execute(array $param = array()) { foreach ($param as &$p) { if($p instanceof \DateTime) $p = $p->format('Y-m-d\TH:i:s'); } $this->stmt->execute($param); $this->initStmt($this->db->getDialect()); $this->executed = true; } public function getColumns() { if(!$this->executed) throw new IllegalStateException('statement not executed'); return $this->getColumns(); } public function getColumnInfo($column) { if(!$this->executed) throw new IllegalStateException('statement not executed'); return $this->_getColumnInfo($column); } public function getColumnCount() { if(!$this->executed) throw new IllegalStateException('statement not executed'); return $this->_getColumnCount(); } public function getRowNumber() { if(!$this->executed) throw new IllegalStateException('statement not executed'); return $this->_getRowNumber(); } public function fetchRow() { if(!$this->executed) throw new IllegalStateException('statement not executed'); return $this->_fetchRow(); } public function fetchArray() { if(!$this->executed) throw new IllegalStateException('statement not executed'); return $this->_fetchArray(); } public function fetchObject($class = false, $param = array()) { if(!$this->executed) throw new IllegalStateException('statement not executed'); return $this->_fetchObject($class, $param); } public function getRowCount() { if(!$this->executed) throw new IllegalStateException('statement not executed'); return $this->_getRowCount(); } public function free() { $this->executed = false; if(is_object($this->stmt)) $this->stmt->closeCursor(); } public function close() { $this->free(); $this->stmt = NULL; } }