Commit d7d332f3 authored by Oliver Bayes-Shelton's avatar Oliver Bayes-Shelton

Updated the MysqliDb.php file to work with php 5.3

Updated the MysqliDb.php file to work with php 5.3+ be removing call by reference and adding a refValues method.
parent 5019f88f
...@@ -105,10 +105,11 @@ class MysqliDB { ...@@ -105,10 +105,11 @@ class MysqliDB {
$params = array(''); // Create the empty 0 index $params = array(''); // Create the empty 0 index
foreach ($bindParams as $prop => $val) { foreach ($bindParams as $prop => $val) {
$params[0] .= $this->_determineType($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(); $stmt->execute();
...@@ -343,7 +344,7 @@ class MysqliDB { ...@@ -343,7 +344,7 @@ class MysqliDB {
if ($hasTableData) { if ($hasTableData) {
$this->_bindParams[0] = $this->_paramTypeList; $this->_bindParams[0] = $this->_paramTypeList;
foreach ($tableData as $prop => $val) { foreach ($tableData as $prop => $val) {
array_push($this->_bindParams, &$tableData[$prop]); array_push($this->_bindParams, $tableData[$prop]);
} }
} }
// Prepare where condition bind parameters // Prepare where condition bind parameters
...@@ -351,13 +352,13 @@ class MysqliDB { ...@@ -351,13 +352,13 @@ class MysqliDB {
if ($this->_where) { if ($this->_where) {
$this->_bindParams[0] .= $this->_whereTypeList; $this->_bindParams[0] .= $this->_whereTypeList;
foreach ($this->_where as $prop => $val) { foreach ($this->_where as $prop => $val) {
array_push($this->_bindParams, &$this->_where[$prop]); array_push($this->_bindParams, $this->_where[$prop]);
} }
} }
} }
// Bind parameters to statment // Bind parameters to statment
if ($hasTableData || $hasConditional){ 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; return $stmt;
...@@ -378,10 +379,10 @@ class MysqliDB { ...@@ -378,10 +379,10 @@ class MysqliDB {
$meta = $stmt->result_metadata(); $meta = $stmt->result_metadata();
while ($field = $meta->fetch_field()) { 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()) { while ($stmt->fetch()) {
$x = array(); $x = array();
...@@ -410,4 +411,16 @@ class MysqliDB { ...@@ -410,4 +411,16 @@ class MysqliDB {
$this->_mysqli->close(); $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 } // END class
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment