Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions MysqliDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ public function rawQuery($query, $bindParams = NULL)
$params = array(''); // Create the empty 0 index
foreach ($bindParams as $prop => $val) {
$params[0] .= $this->_determineType($val);
array_push($params, &$bindParams[$prop]);
array_push($params, $bindParams[$prop]);
}

call_user_func_array(array($stmt, 'bind_param'), $params);
call_user_func_array(array($stmt, "bind_param"),$this->refValues($params));

}

$stmt->execute();
Expand Down Expand Up @@ -343,21 +344,21 @@ protected function _buildQuery($numRows = NULL, $tableData = NULL)
if ($hasTableData) {
$this->_bindParams[0] = $this->_paramTypeList;
foreach ($tableData as $prop => $val) {
array_push($this->_bindParams, &$tableData[$prop]);
array_push($this->_bindParams, $tableData[$prop]);
}
}
// Prepare where condition bind parameters
if($hasConditional) {
if ($this->_where) {
$this->_bindParams[0] .= $this->_whereTypeList;
foreach ($this->_where as $prop => $val) {
array_push($this->_bindParams, &$this->_where[$prop]);
array_push($this->_bindParams, $this->_where[$prop]);
}
}
}
// Bind parameters to statment
if ($hasTableData || $hasConditional){
call_user_func_array(array($stmt, 'bind_param'), $this->_bindParams);
call_user_func_array(array($stmt, "bind_param"),$this->refValues($this->_bindParams));
}

return $stmt;
Expand All @@ -378,10 +379,10 @@ protected function _dynamicBindResults($stmt)
$meta = $stmt->result_metadata();

while ($field = $meta->fetch_field()) {
array_push($parameters, &$row[$field->name]);
array_push($parameters, $row[$field->name]);
}

call_user_func_array(array($stmt, 'bind_result'), $parameters);
call_user_func_array(array($stmt, "bind_result"),$this->refValues($parameters));

while ($stmt->fetch()) {
$x = array();
Expand Down Expand Up @@ -410,4 +411,16 @@ public function __destruct()
$this->_mysqli->close();
}

function refValues($arr)
{
//Reference is required for PHP 5.3+
if (strnatcmp(phpversion(),'5.3') >= 0) {
$refs = array();
foreach($arr as $key => $value)
$refs[$key] = &$arr[$key];
return $refs;
}
return $arr;
}

} // END class