Call Postgresql functions

hello

How I can call or use postgresql functions in yii 2?

In database, postgresql function:

CREATE OR REPLACE FUNCTION concat_text(text, text)

RETURNS text AS

$BODY$

BEGIN


    RETURN $1 || $2;


END;

$BODY$

LANGUAGE plpgsql VOLATILE

COST 100;

In controller:


public function actionConcat_text() {

        $command = Yii::$app->db->createCommand("SELECT concat_text('conn', 'ected')");

        $data = $command->query();

        foreach ($data as $d) {

            $arr[] = implode("", $d);

        }

        return $this->render('display_txt', [

            'arr' => $arr[0],

        ]);

}

Test it in display_txt.php file in ‘view’ folder:


<?php

     echo $arr;    

?>

That worked

thanks…