* @package Mammut\DB\Adapter\Oracle */ class Statement extends \Mammut\DB\Statement { private $stmt; private $pstmt; private $pcount; public function __construct($dbCon, $stmt) { $this->db = $dbCon; $this->pcount = substr_count($stmt, '?'); $parts = explode('?', $stmt); $newquery = ''; for($i = 0; $i < count($parts) - 1; $i++) { $newquery .= current($parts); $newquery .= ':var' . $i; next($parts); } $newquery .= current($parts); $this->stmt = $newquery; $this->pstmt = oci_parse($dbCon, $newquery); } public function execute(array $param = array()) { if($this->pcount != count($param)) throw new \Mammut\Exception\IllegalStateException('wrong parameter count, needs to be ' . substr_count($this->stmt, '?') . ', but ' . count($param) . ' given'); foreach($param as $key=>$value) { $name = ':var' . $key; oci_bind_by_name($this->pstmt, $name, $param[$key]); } $ok = oci_execute($this->pstmt); $errors = oci_error($this->pstmt); if(!$ok) throw new SQLException(Oracle::buildErrorString($errors), $query); $this->result = new Result($this->pstmt); } }