Commit f690648b authored by Jeffrey Way's avatar Jeffrey Way

Fixed update and where method glitches

parent 809dfa54
...@@ -43,7 +43,7 @@ class MysqlDB { ...@@ -43,7 +43,7 @@ class MysqlDB {
$stmt->execute(); $stmt->execute();
$results = $this->_dynamicBindResults($stmt); $results = $this->_dynamicBindResults($stmt);
return $results; return $results;
} }
...@@ -118,21 +118,21 @@ class MysqlDB { ...@@ -118,21 +118,21 @@ class MysqlDB {
protected function _determineType($item) protected function _determineType($item)
{ {
switch (gettype($item)) { switch (gettype($item)) {
case 'string': case 'string':
return 's'; return 's';
break; break;
case 'integer': case 'integer':
return 'i'; return 'i';
break; break;
case 'blob': case 'blob':
return 'b'; return 'b';
break; break;
case 'double': case 'double':
return 'd'; return 'd';
break; break;
} }
} }
...@@ -162,23 +162,23 @@ class MysqlDB { ...@@ -162,23 +162,23 @@ class MysqlDB {
// and create the SQL query, accordingly. // and create the SQL query, accordingly.
if ($hasTableData) { if ($hasTableData) {
$i = 1; $i = 1;
$pos = strpos($this->_query, 'UPDATE'); $pos = strpos($this->_query, 'UPDATE');
if ( $pos !== false) { if ( $pos !== false) {
$this->_crudType = 'update'; $this->_crudType = 'update';
foreach ($tableData as $prop => $value) { foreach ($tableData as $prop => $value) {
// determines what data type the item is, for binding purposes. // determines what data type the item is, for binding purposes.
$this->_paramTypeList .= $this->_determineType($value); $this->_paramTypeList .= $this->_determineType($value);
// prepares the reset of the SQL query. // prepares the reset of the SQL query.
if ($i === count($tableData)) { if ($i === count($tableData)) {
$this->_query .= $prop . " = ? WHERE $where_prop = '$where_value'"; $this->_query .= $prop . " = ? WHERE $where_prop = '$where_value'";
} else { } else {
$this->_query .= $prop . ' = ?, '; $this->_query .= $prop . ' = ?, ';
} }
$i++; $i++;
} }
} }
} else { } else {
// no table data was passed. Might be SELECT statement. // no table data was passed. Might be SELECT statement.
$this->_paramTypeList = $this->_determineType($where_value); $this->_paramTypeList = $this->_determineType($where_value);
...@@ -265,9 +265,9 @@ class MysqlDB { ...@@ -265,9 +265,9 @@ class MysqlDB {
/** /**
* Method attempts to prepare the SQL query * Method attempts to prepare the SQL query
* and throws an error if there was a problem. * and throws an error if there was a problem.
*/ */
protected function _prepareQuery() protected function _prepareQuery()
{ {
if (!$stmt = $this->_mysql->prepare($this->_query)) { if (!$stmt = $this->_mysql->prepare($this->_query)) {
...@@ -279,7 +279,7 @@ class MysqlDB { ...@@ -279,7 +279,7 @@ class MysqlDB {
public function __destruct() public function __destruct()
{ {
$this->_mysql->close(); $this->_mysql->close();
} }
} }
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