Reputation: 352
I need to findout the normal sql query for the below. Can you guys please suggest me how can i achieve in Symfony.
Example:
$r = Doctrine_Query::create()
->select('u.worked_hours')
->from('tasksComments u')
->where('u.tasks_id = ?', $arr_values['tasks_id'])
->andwhere('u.id != ?', $arr_values['id'])
->andwhere('u.created_at LIKE ?', $date."%");
$results1 = $r->execute();
Upvotes: 0
Views: 13740
Reputation: 291
You can view all the executed queries in the profiler toolbar by clicking on the db panel icon (the last section of the toolbar) then on the [Display runnable query] link under your query.
Upvotes: 0
Reputation: 6256
On the query object, use the method getSQL
.
In your case:
$r = Doctrine_Query::create()
->select('u.worked_hours')
->from('tasksComments u')
->where('u.tasks_id = ?', $arr_values['tasks_id'])
->andwhere('u.id != ?', $arr_values['id'])
->andwhere('u.created_at LIKE ?', $date."%");
var_dump($r->getSQL()); // print the SQL query - you will need to replace the parameters in the query
var_dump($r->getParams()); // print the parameters of the query so you can easily replace the missing parameters in the query
Note that I don't know the namespace of Doctrine_Query
but I am assuming that your Query
object in this Query object in the Doctrine API documentation.
Upvotes: 7