public function execute($params = null)
{
if (null !== $this->_bindedValues) {
if (null !== $params) {
if (!$this->_bindValues($params)) {
throw new MysqliException($this->_stmt->error, $this->_stmt->errno);
}
} else {
if (!call_user_func_array(array($this->_stmt, 'bind_param'), array($this->types) + $this->_bindedValues)) {
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
}
}
}
if (!$this->_stmt->execute()) {
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
}
if (null === $this->_columnNames) {
$meta = $this->_stmt->result_metadata();
if (false !== $meta) {
// We have a result.
$this->_stmt->store_result();
$columnNames = array();
foreach ($meta->fetch_fields() as $col) {
$columnNames[] = $col->name;
}
$meta->free();
$this->_columnNames = $columnNames;
$this->_rowBindedValues = array_fill(0, count($columnNames), null);
$refs = array();
foreach ($this->_rowBindedValues as $key => &$value) {
$refs[$key] =& $value;
}
if (!call_user_func_array(array($this->_stmt, 'bind_result'), $refs)) {
throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno);
}
} else {
$this->_columnNames = false;
}
}
return true;
}