What is the best way to display information about a specific user from the database? For example, his login, password, date of birth.
fetchrow`ом Or are there analogues of this "operation"?
What is the best way to display information about a specific user from the database? For example, his login, password, date of birth.
fetchrow`ом Or are there analogues of this "operation"?
PDO is best to use:
public static function LoadFromTable($id){ $DBH = Registry::get('DBH'); $STH = $DBH ->prepare("SELECT * FROM users WHERE id = :id"); // забираем информацию о юзере по id $STH->bindParam(':id', $id, PDO::PARAM_STR); // или PARAM_INT $STH->execute(); $result = $STH->fetchAll(); return $result; // вернет ассоциативный массив } For more details look at my answer here , well, do not forget about the office. php.net PDO documentation.
Registry::get('DBH') (although you can guess). - user31688Shta
Choose with select , pick up from the response object via fetch - if through PDO.
Source: https://ru.stackoverflow.com/questions/408990/
All Articles