Skip to main content
added 2 characters in body
Source Link
Alex L
  • 5.8k
  • 2
  • 26
  • 69

With pdoPDO, you wouldcould have:

$getStuff = $pdo->prepare('SELECT `question`, `answer` FROM `Quizzes` WHERE `questionNumber`< :questionNumber ORDER BY `questionNumber` ASC');

$getStuff->execute(array('questionNumber' => 21));

$rows = $getStuff->fetchAll();

foreach($rows as $row)
{
   $questions[] = $row['question'];
   $answers[]   = $row['answer'];
}

It's up to you to decide if removing the binding stuff makes the code any easier to read and maintain.

With pdo you would have:

$getStuff = $pdo->prepare('SELECT `question`, `answer` FROM `Quizzes` WHERE `questionNumber`< :questionNumber ORDER BY `questionNumber` ASC');

$getStuff->execute(array('questionNumber' => 21);

$rows = $getStuff->fetchAll();

foreach($rows as $row)
{
   $questions[] = $row['question'];
   $answers[]   = $row['answer'];
}

It's up to you to decide if removing the binding stuff makes the code any easier to read and maintain.

With PDO, you could have:

$getStuff = $pdo->prepare('SELECT `question`, `answer` FROM `Quizzes` WHERE `questionNumber`< :questionNumber ORDER BY `questionNumber` ASC');

$getStuff->execute(array('questionNumber' => 21));

$rows = $getStuff->fetchAll();

foreach($rows as $row)
{
   $questions[] = $row['question'];
   $answers[]   = $row['answer'];
}

It's up to you to decide if removing the binding stuff makes the code any easier to read and maintain.

Source Link
Cerad
  • 291
  • 1
  • 3

With pdo you would have:

$getStuff = $pdo->prepare('SELECT `question`, `answer` FROM `Quizzes` WHERE `questionNumber`< :questionNumber ORDER BY `questionNumber` ASC');

$getStuff->execute(array('questionNumber' => 21);

$rows = $getStuff->fetchAll();

foreach($rows as $row)
{
   $questions[] = $row['question'];
   $answers[]   = $row['answer'];
}

It's up to you to decide if removing the binding stuff makes the code any easier to read and maintain.