Я медленно перемещаю все мои функции LAMP websites
из mysql_
в функции PDO
, и я ударил свою первую кирпичную стену. Я не знаю, как перебирать результаты с помощью параметра. Я в порядке со следующим:
foreach ($database->query("SELECT * FROM widgets") as $results)
{
echo $results["widget_name"];
}
Однако, если я хочу сделать что-то вроде этого:
foreach ($database->query("SELECT * FROM widgets WHERE something='something else'") as $results)
{
echo $results["widget_name"];
}
Очевидно, что "что-то еще" будет динамическим.