Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

query execute to Array

I have a query:

public static function fnGetMenuBySuper($i_super_menu = null, $b_all = false) {
    $builder =  $di->get('modelsManager')->createBuilder();
                $o_select = $builder->columns(
                                array(
                                    "IF(mo.idModule IS NOT NULL, IF(mo.status = 1,1,0),1) as menu_module_ok", 'me.idMenu as menu_id',
                                    'me.idSuperMenu as menu_super_id',
                                    'me.name as menu_name',
                                    'me.type as menu_type',
                                    'me.icon as menu_icon',
                                    'me.url as menu_url',
                                    'me.optionKey as menu_option_key',
                                    'me.optionKeyValue as menu_option_value'))
                        ->from(array('me' => 'Models\BtsMenu'))
                        ->leftJoin('Models\BtsModule', 'me.idModule = mo.idModule', 'mo');

                if (!$b_all)
                    $o_select->where('me.idSuperMenu = :idSuperMenu:', array('idSuperMenu' => $i_super_menu));

                $a_menu = $o_select->where('me.status = :status:', array('status' => self::BTS_STATUS_ACTIVE))
                        ->getQuery()
                        ->execute()
                        ->setHydrateMode(Resultset::HYDRATE_ARRAYS);
                        return $a_menu;
                        }

$a_select_menu = \Models\BtsMenu::fnGetMenuBySuper(null, true);

when try with: 

var_dump($a_select_menu) ;
i expect a array but the result is: object(Phalcon\Mvc\Model\Resultset\Simple)[176]

Any Help?



11.5k
Accepted
answer

The solutions...

 return $a_menu->toArray();