I'm trying to make an ORM, I have a function to get a queryString but I got an error
"Notice: Array to string conversion"
I don't know how to solve it. If you can help me, it's could be very nice, thanks
public function selectOrderBy($columnName,$order){
$req = $this->getConnexion()->query('SELECT * FROM '.$this->getTable().' ORDER BY '.$columnName.' '.$order.'');
$req->execute();
$this->logRequest($req->queryString);
$results = $req->fetchAll();
return $results;
}
function logRequest($query){
$date = new DateTime();
$dateString = $date->format('Y-m-d H:i:s');
$filePath = "request.log";
$fp = fopen($filePath, "a+");
fputs($fp, "[".date('d/m/Y à H:i:s',time())."]" . $query ); //Error here
fclose($fp);
}
On file request.log I've got this
[04/01/2019 à 10:18:05]SELECT * FROM animals ORDER BY id ASC
[04/01/2019 à 10:18:05]SELECT * FROM animals ORDER BY id ASC
[04/01/2019 à 10:18:05]Array
And I use this in other file
$manager->logRequest($manager->selectOrderBy('id','ASC'));
$querydate()function does not require thetime()parameter unless that is not the current timegeneral_logwill give you exactly what you want. Dont roll your own.