0

我在我的 oracle 数据库中开发了一个 SQL 函数:

     创建或替换函数 test (var in number) 返回号为
     开始
     返回 888;
     结尾;
     /

在 sql 中,我可以像这样调用这个函数:


    从 dual 中选择 test(1) 作为 res;

如何在 symfony2.0 教义 2.2 中正确调用 SQL 函数?我试过这个:

        $query = $this->createQueryBuilder('DUAL')->select("FUNCTION('test1',1) as res");
        die(var_dump($query->getQuery()->getResult()));

它有效,但响应太多行,我不知道为什么:

    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] => 数组(1){ 'res' => 字符串(3)“888” } [5] => 数组(1){ 'res' => 字符串(3)“888” } [6] => 数组( 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' =>字符串(3) "888" } [11] => 数组(1) { 'res' => 字符串(3) "888" } [12] =>数组(1){'res'=>字符串(3)“888”}[13]=>数组(1){'res'=>字符串(3)“888”}[14]=>数组(1) { 'res' => 字符串(3) "888" } }

4

1 回答 1

1

请查看有关向 Symfony 添加自定义 DQL 函数的相应文章:

http://symfony.com/doc/current/cookbook/doctrine/custom_dql_functions.html

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/dql-user-defined-functions.html

于 2013-07-15T10:27:59.993 回答