08-15-2017, 11:25 PM
So it appears that that the query in the DB class is not ideal for Insert or Update statements.
The following two lines in the query function are not available to insert or update statements as nothing is returned and as such the Fatal error above is being produced.
All I did was create a query2 function and commented out the two lines. I then updated my Insert statement to use the query2 function instead of the query function.
mudmin I'd like to get your thoughts on the above? Is this change safe to make or do you see it breaking something else?
I am running 4.2.6 this may be sorted in a later release. I assume it will break once I upgrade if not.
The following two lines in the query function are not available to insert or update statements as nothing is returned and as such the Fatal error above is being produced.
Quote:$this->_results = $this->_query->fetchALL(PDO::FETCH_OBJ);
$this->_resultsArray = json_decode(json_encode($this->_results),true);
All I did was create a query2 function and commented out the two lines. I then updated my Insert statement to use the query2 function instead of the query function.
Quote:public function query2($sql, $params = array()){
$this->_queryCount++;
$this->_error = false;
if ($this->_query = $this->_pdo->prepare($sql)) {
$x = 1;
if (count($params)) {
foreach ($params as $param) {
$this->_query->bindValue($x, $param);
$x++;
}
}
if ($this->_query->execute()) {
#$this->_results = $this->_query->fetchALL(PDO::FETCH_OBJ);
#$this->_resultsArray = json_decode(json_encode($this->_results),true);
$this->_count = $this->_query->rowCount();
$this->_lastId = $this->_pdo->lastInsertId();
} else{
$this->_error = true;
}
}
return $this;
}
mudmin I'd like to get your thoughts on the above? Is this change safe to make or do you see it breaking something else?
I am running 4.2.6 this may be sorted in a later release. I assume it will break once I upgrade if not.