I developed a SQL function in my oracle database :
create or replace function test (var in number) return number is begin return 888; end; /
In sql, I can call this function like this :
select test(1) as res from dual;
How can I call SQL function properly in symfony2.0 doctrine 2.2 ? I tried with this :
$query = $this->createQueryBuilder('DUAL')->select("FUNCTION('test1',1) as res"); die(var_dump($query->getQuery()->getResult()));
It works but it respond with too many lines and I don't know why :
array(15) { [0] => array(1) { 'res' => string(3) "888" } [1] => array(1) { 'res' => string(3) "888" } [2] => array(1) { 'res' => string(3) "888" } [3] => array(1) { 'res' => string(3) "888" } [4] => array(1) { 'res' => string(3) "888" } [5] => array(1) { 'res' => string(3) "888" } [6] => array(1) { 'res' => string(3) "888" } [7] => array(1) { 'res' => string(3) "888" } [8] => array(1) { 'res' => string(3) "888" } [9] => array(1) { 'res' => string(3) "888" } [10] => array(1) { 'res' => string(3) "888" } [11] => array(1) { 'res' => string(3) "888" } [12] => array(1) { 'res' => string(3) "888" } [13] => array(1) { 'res' => string(3) "888" } [14] => array(1) { 'res' => string(3) "888" } }
Please check the corresponding articles about adding a custom DQL function to Symfony:
http://symfony.com/doc/current/cookbook/doctrine/custom_dql_functions.html