- shows имеет show_id в качестве первичного ключа.
- games имеет game_id в качестве первичного ключа.
Я я использую огромный/panique на GitHub.
В нем есть контроллеры, модели, представления.
Вот мой код контроллера:
Код: Выделить всё
public function details($show_id)
{
$this->View->render('shows/details', array(
'venues' => VenuesModel::getVenue($show_id),
'payment_types' => AdminModel::getPaymentTypes(),
'products' => AdminModel::getAllProducts(),
'games' => ShowsModel::getAllGames($show_id)
));
}
Код: Выделить всё
public static function getAllGames($show_id)
{
$database = DatabaseFactory::getFactory()->getConnection();
$sql =
"SELECT * FROM
games
WHERE show_id = :show_id"
;
$query = $database->prepare($sql);
$query->execute(array(
':show_id' => $show_id
));
// fetch() is the PDO method that gets a single result
return $query->fetch();
}
Код: Выделить всё
game_id (primary key)
show_id
Код: Выделить всё
Warning: Attempt to read property "game_id" on int in /home/foxtangocharlie/a.xftc.co/application/view/shows/details.php on line 20
Код: Выделить всё
Warning: Attempt to read property "show_id" on int in /home/foxtangocharlie/a.xftc.co/application/view/shows/details.php on line 21
Подробнее здесь: https://stackoverflow.com/questions/791 ... -id-on-int