public function select($select,$table, $where) { $data = $this -> pdo->prepare('SELECT :select FROM :table WHERE :where '); $data -> bindParam(':table',$table); $data -> bindParam(':select',$select); $data -> bindParam(':where',$where); $data ->execute(); return $data; } 1 answer
I think you need to write this:
public function selectById($id) { $data = $this->pdo->prepare('SELECT `login` FROM `tbl_user` WHERE `id` = :id'); $data->bindParam(':id',$id, \PDO::PARAM_INT); $data->execute(); return $data->fetchAll(); } In prepared queries, you cannot dynamically select select and table. Only parameters for search. With queries of the same type, this gives a performance boost if you stored $data in a variable and would not create it every time.
and here is the link on http://phpfaq.ru/pdo
- Thank! I will sort this out ! - Hlud09
|
tableand in the sample betweenselectandfrom..... - Alexey ShimanskyloginFROMtbl_userWHERE id =?"; $ name = $ this -> pdo -> prepare ($ sql); $ name-> excute (array ($ user)); - Hlud09