I'm trying to execute this:
$colparam = 'abcd'; $stmt = $db->prepare("SELECT DISTINCT ? AS kol FROM katalog ORDER BY kol ASC"); $stmt->execute(array($colparam)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); and it's not working (no errors, just empty array as result).
Instead this works fine:
$stmt = $db->prepare("SELECT DISTINCT abcd AS kol FROM katalog ORDER BY kol ASC"); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); So is there any catch with the use of parameter as a name of the column in PDO?
menus(id, choice1, choice2, choice3, ...)