Commit 76cc087b authored by Alexander Butenko's avatar Alexander Butenko

Add _bindParam internal helper function

parent b0d971fc
...@@ -420,6 +420,17 @@ class MysqliDb ...@@ -420,6 +420,17 @@ class MysqliDb
return ''; return '';
} }
/**
* Helper function to add variables into bind parameters array
*
* @param string Variable value
*/
protected function _bindParam($value)
{
$this->_bindParams[0] .= $this->_determineType ($value);
array_push ($this->_bindParams, $value);
}
/** /**
* Abstraction method that will compile the WHERE statement, * Abstraction method that will compile the WHERE statement,
* any passed update data, and the desired rows. * any passed update data, and the desired rows.
...@@ -458,8 +469,7 @@ class MysqliDb ...@@ -458,8 +469,7 @@ class MysqliDb
$this->_query .= $column." = "; $this->_query .= $column." = ";
if (!is_array ($value)) { if (!is_array ($value)) {
$this->_bindParams[0] .= $this->_determineType($value); $this->_bindParam ($value);
array_push ($this->_bindParams, $value);
$this->_query .= '?, '; $this->_query .= '?, ';
} else { } else {
$key = key ($value); $key = key ($value);
...@@ -471,10 +481,8 @@ class MysqliDb ...@@ -471,10 +481,8 @@ class MysqliDb
case '[F]': case '[F]':
$this->_query .= $val[0] . ", "; $this->_query .= $val[0] . ", ";
if (!empty ($val[1])) { if (!empty ($val[1])) {
foreach ($val[1] as $v) { foreach ($val[1] as $v)
$this->_bindParams[0] .= $this->_determineType($v); $this->_bindParam ($v);
array_push ($this->_bindParams, $v);
}
} }
break; break;
case '[N]': case '[N]':
...@@ -512,29 +520,24 @@ class MysqliDb ...@@ -512,29 +520,24 @@ class MysqliDb
$comparison = ' IN ('; $comparison = ' IN (';
foreach($val as $v){ foreach($val as $v){
$comparison .= ' ?,'; $comparison .= ' ?,';
$this->_bindParams[0] .= $this->_determineType( $v ); $this->_bindParam ($v);
array_push ($this->_bindParams, $v);
} }
$comparison = rtrim($comparison, ',').' ) '; $comparison = rtrim($comparison, ',').' ) ';
break; break;
case 'between': case 'between':
$comparison = ' BETWEEN ? AND ? '; $comparison = ' BETWEEN ? AND ? ';
$this->_bindParams[0] .= $this->_determineType( $val[0] ); $this->_bindParam ($val[0]);
$this->_bindParams[0] .= $this->_determineType( $val[1] ); $this->_bindParam ($val[1]);
array_push ($this->_bindParams, $val[0]);
array_push ($this->_bindParams, $val[1]);
break; break;
default: default:
// We are using a comparison operator with only one parameter after it // We are using a comparison operator with only one parameter after it
$comparison = ' '.$key.' ? '; $comparison = ' '.$key.' ? ';
// Determines what data type the where column is, for binding purposes. // Determines what data type the where column is, for binding purposes.
$this->_bindParams[0] .= $this->_determineType( $val ); $this->_bindParam ($val);
array_push ($this->_bindParams, $val);
} }
} else { } else {
// Determines what data type the where column is, for binding purposes. // Determines what data type the where column is, for binding purposes.
$this->_bindParams[0] .= $this->_determineType($value); $this->_bindParam ($value);
array_push ($this->_bindParams, $value);
} }
// Prepares the reset of the SQL query. // Prepares the reset of the SQL query.
$this->_query .= ($andOr.$column.$comparison); $this->_query .= ($andOr.$column.$comparison);
......
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