Merge branch 'fronkdev' into 'master'
Fixed treating successful mysql queries as error when warnings are generated See merge request fronk/thetool!972
This commit is contained in:
@@ -7,6 +7,8 @@ class FronkDB {
|
|||||||
private $lastError;
|
private $lastError;
|
||||||
private $log;
|
private $log;
|
||||||
|
|
||||||
|
public $insert_id;
|
||||||
|
|
||||||
private static $instances = [];
|
private static $instances = [];
|
||||||
|
|
||||||
//private static $instance;
|
//private static $instance;
|
||||||
@@ -71,6 +73,9 @@ class FronkDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function query($sql, $print_error = false) {
|
public function query($sql, $print_error = false) {
|
||||||
|
// unset last insert id on qvery new query
|
||||||
|
$this->insert_id = null;
|
||||||
|
|
||||||
if(!$this->link) {
|
if(!$this->link) {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
}
|
}
|
||||||
@@ -103,6 +108,8 @@ class FronkDB {
|
|||||||
$this->log->warn("SQL Last Error: ".$this->lastError);
|
$this->log->warn("SQL Last Error: ".$this->lastError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->insert_id = mysqli_insert_id($this->link);
|
||||||
|
|
||||||
// check for warnings
|
// check for warnings
|
||||||
if(mysqli_warning_count($this->link) > 0) {
|
if(mysqli_warning_count($this->link) > 0) {
|
||||||
$log_query = true;
|
$log_query = true;
|
||||||
|
|||||||
@@ -185,7 +185,8 @@ class mfBaseModel {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if($this->db->insert($this->table, $fields, $forcestr)) {
|
if($this->db->insert($this->table, $fields, $forcestr)) {
|
||||||
$id = mysqli_insert_id($this->db->link);
|
$id = $this->db->insert_id;
|
||||||
|
var_dump($id);
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->saved++;
|
$this->saved++;
|
||||||
if(method_exists($this, "afterSave")) {
|
if(method_exists($this, "afterSave")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user