I am trying to deduce information about several apartments from the database with the following query, it is certainly long, but (it seems to me, special attention should be paid to the IN condition):
$stmt = $pdo->prepare("SELECT flats.*, sort.value as sort, street.name as street, district.name as district, type.name as type, underground.name as underground, `line`.name as `line` FROM flats join sort on flats.sort=sort.id_sort join district on flats.district=district.id_district join street on street.id_street=flats.street join underground on underground.id_underground= flats.underground join type on type.id_type=flats.type join `line` on `line`.id_line=underground.line where id in (:id)"); $stmt->execute(array('id' => $str)); Two or three numbers are written in $ str, I check in phpMyAdmin - that's right, it displays the required number of lines. And then I try to output it on the site itself and get an array that contains the following:
Array ( [0] => Array ( [id] => 1 [sort] => Студия [district] => Чертаново Южное [street] => Варшавское шоссе [underground] => Динамо [jk] => [floorf] => 5 [numb] => 1 [floorh] => 17 [elevator] => 2 [type] => Панельный [rooms] => 2 [floor] => 1 [price] => 5000000.99 [size] => 50.00 [bathroom] => 1 [balcony] => 1 [img] => 1q.jpg [popular] => 1 [enabled] => 1 [created_at] => 2016-10-21 22:41:50 [updated_at] => [line] => Замоскворецкая линия ) ) As a result, contains information about only one apartment.
I deduce as follows: $ res = $ stmt-> fetchAll (); print_r ($ res);
What am I doing wrong, where does the second go?
id in(?,?,?)(number of questions equals the number of transmitted id) andexecute(explode(',',$str))- Mike