I have created a class user which reflects row in a user table. There is one method populate in which I am fetching values from database based on primary key and try to store it in self object. I can do it by getting all variables and setting them one by one per field. Is there any way to do it using PDO::FETCH_CLASS or any other simple method ?
If I try to store it using $this = $stmt->fetch( PDO::FETCH_CLASS ) it gives Fatal error: Cannot re-assign $this in /var/www/html/php/classes.php on line 51 error.
I don't want to use ORM style tools and want to develop the class by my own.