1
$PDO = Doctrine_Manager::getInstance()->connection()->getDbh();
$PDO->prepare("
      //SQL Query Here
")->execute();

I was told that this will work for creating a custom Doctrine query in Symfony. Regardless of what I put inside the prepare statement I get a value of 1 returned. Print_r of the returned variable gives 11. How odd... what is going on?

whamsicore
  • 8,320
  • 9
  • 40
  • 50

1 Answers1

1

That's because execute() returns TRUE on success and FALSE on FAILURE: http://pl.php.net/manual/en/pdostatement.execute.php

You should use one of the fetch* methods to actually retrieve data: http://pl.php.net/manual/en/pdostatement.fetchall.php

Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125
  • print_r(output) gives me "sfOutputEscaperArrayDecorator Object ( [count:private] => 0 [value:protected] => Array ( ) [escapingMethod:protected] => esc_specialchars ) " any ideas? – whamsicore Jan 22 '11 at 09:05
  • nm got it: had to run execute() first, and then use fetchAll(); Thanks very much. – whamsicore Jan 22 '11 at 09:14