* @package Mammut\DB\Adapter\DB2 */ class Statement extends \Mammut\DB\Statement { private $stmt; public function __construct(DB2 $database, $stmt) { $this->db = $database; $this->stmt = $stmt; } public function setParam(array $param) { $this->param = $param; } public function execute(array $param = array(), $limit = -1, $skip = 0) { if(substr_count($this->query, '?') != count($this->param)) throw new IllegalStateException('wrong parameter count, needs to be ' . substr_count($this->query, '?')); $parts = explode('?', $this->query); $newquery = ''; foreach($this->param as $p) { $newquery .= current($parts); $newquery .= $this->db->escapeValue($p); next($parts); } $newquery .= current($parts); $this->result = $this->db->query($this->query); } }