3

如何在 Symfony2 中调用存储过程?

我在 PostgreSQL 中创建了一个名为的存储过程,get_manhours_all()它返回以下结果:

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

Symfony2 中是否有方法可以调用get_manhours_all()- 本机查询是SELECT get_manhours_all();.

4

1 回答 1

1

不,没有 Symfony 2 方法来调用您的 SP,因为它存储在您的数据库中。您应该使用Native SQL进行如下调用,

$conn      = $this->get('database_connection');
$statement = $conn->executeQuery('/*SQL Call to your stored procedure*/');
$results   = $statement->fetchAll();
于 2013-03-19T11:03:03.237 回答