如何在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()
的方法 - native 查询是 SELECT get_manhours_all();
。
最佳答案
不,没有 Symfony 2 方法来调用您的 SP,因为它存储在您的数据库中。您应该使用 Native SQL 进行此类调用如下,
$conn = $this->get('database_connection');
$statement = $conn->executeQuery('/*SQL Call to your stored procedure*/');
$results = $statement->fetchAll();
关于postgresql - 在 Symfony2 和 PostgreSQL 中调用存储过程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15495415/