dsogx84602
dsogx84602
2013-06-21 09:02

使用Phalcon \ Mvc \ Model \ Query \ Builder时清空结果集

已采纳

Good day, eveyrone!

I'm trying to fetch data from Oracle database via Phalcon\Mvc\Model\Query\Builder, but resultset allways empty.

// APPLICATION_ROOT/app/models/Package.php
<?php

use Phalcon\MVC\Model;

class Package extends Model
{
    public function getSource()
    {
        return 'RADIO_PACKAGE';
    }
}

The controller class:

public function indexAction()
{
    $packages = Package::find();
    var_dump($packages->toArray()); // null

    $query = $this->modelsManager->createBuilder()->from('Package')->getQuery();
    var_dump($query->execute()->toArray()); // null

    // But the direct access to database returns rows
    $PDO = $this->getDI()->get('db')->getInternalHandler();
    var_dump($PDO->query('SELECT * FROM RADIO_PACKAGE')->fetchAll()); // returns 23 rows
}

Does anyone know what the problem is?

I tried Phalcon 1.1.0 and 1.2.0.

PDO_OCI driver has been installed from PHP 5.4.16 source.

PHP version is 5.4.11.

Oracle version is "Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit"

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dongwei1234 dongwei1234 8年前
    点赞 评论 复制链接分享
  • droe9376 droe9376 8年前

    Do you have in public/index.php a setup for Loader ? Something like

    $loader = new \Phalcon\Loader();
    $loader->registerDirs(
        array(
            $config->application->controllersDir,
            $config->application->modelsDir,
                        $config->application->pluginsDir
        )
    )->register();
    
    点赞 评论 复制链接分享

相关推荐