Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute custom SQL in symfony

I'm trying to execute some custom SQL to retrieve some model objects in a Symfony application. I found a tutorial on the web that said something like this would allow me to execute the query although not populate the models (populating the model isn't a major issue, it's just for read only data).

$pdo = Doctrine_Manager::getInstance()->connection()->getDbh();
$pdo->prepare("SELECT * from something complicated");
$pdo->execute();
$this->sensorReadings = $pdo->fetchAll();

But I'm getting an error :

Fatal error: Call to undefined method PDO::execute()
in sfproject/apps/frontend/modules/site/actions/actions.class.php 
like image 587
BenCr Avatar asked Mar 16 '11 12:03

BenCr


1 Answers

$query = "SELECT * from something complicated";
$rs = Doctrine_Manager::getInstance()->getCurrentConnection()->fetchAssoc($query);

The resultset is an array.

like image 182
Pabloks Avatar answered Sep 30 '22 17:09

Pabloks