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();
.
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.