Asep Fajar Nugraha
Asep Fajar Nugraha

Reputation: 31

Call stored procedure in Symfony2 and PostgreSQL?

How to call stored procedure in Symfony2?

I created a stored procedure in PostgreSQL named get_manhours_all() which returns the result of this:

select
    sum(
        extract(epoch from end_time) - extract(epoch from begin_time)
    )/3600 as manhours
from timeslot;

Is there a method in Symfony2 to call get_manhours_all() - the native query is SELECT get_manhours_all();.

Upvotes: 3

Views: 928

Answers (1)

Ahmed Siouani
Ahmed Siouani

Reputation: 13891

No, there is no Symfony 2 method to call your SP as it's stored in your database. You should make such a call using Native SQL as follow,

$conn      = $this->get('database_connection');
$statement = $conn->executeQuery('/*SQL Call to your stored procedure*/');
$results   = $statement->fetchAll();

Upvotes: 1

Related Questions