Closed touchweb-vincent closed 3 years ago
I love objects too.
I don't think change FETCH_ASSOC to FETCH_OBJ directly is a good idea. Because that would lose so much compatibility. And for different table I'd like to fetch different class instance.
I opened a pull request #313 to present another implementation.
Hello,
This is my first post on Github, so i apologize if i don't do things in the right way.
I've discover your projet while an R&D session by night and i've decided to migrated my CMS from EZSQLcore to Medoo. You've done a great job on this class.
Here is my request (i could make a pull request in a second time if i take times to understand how it works) :
PDO::FETCH_ASSOC is replaced by PDO::FETCH_OBJ in your function "select".
This could be dynamic by adding a specific configuration in the constructor.
Same thing inside your function "query" : PDO::FETCH_CLASS (is there a bug here when you fire a SELECT ? it seems to duplicate array keys)
Something like that : public function select_row($table, $join, $columns = null, $where = null) { $query = $this->query($this->select_context($table, $join, $columns, $where));
}
Adding $protected show_errors in the class attributes and let us fix it how when want.
So within the catch of the constructor, it will be :
if ($this->show_errors) { $this->sql_statut = 0; throw new Exception($e->getMessage()); } else { $this->sql_statut = 0; }
$sql_statut will be equal to 1 if mysql is UP, 0 else. So we can catch it later.
Best regards, (and thank you for this amazing class)
Vincent