Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalcon\Mvc\Model\Exception: Column "DB_ROWNUM" doesn't make part of the column map #3256

Closed
dancebear opened this issue Jan 20, 2015 · 3 comments

Comments

@dancebear
Copy link
Contributor

<?php
    class Order extends \Phalcon\Mvc\Model {

        /**
         * 预约表的ID
         * @Primary
         * @Identity
         * @Column(type="integer",nullable=false,column="YUYUE_ID")
         * @var int
         */
        public $orderId;

        /**
         * 订单编号
         * @Column(type="integer",nullable=false,column="ORDER_NO")
         * @var int
         */
        public $orderNo;

    }
?>

Order::find();will throw a exception : Phalcon\Mvc\Model\Exception: Column "DB_ROWNUM" doesn't make part of the column map
Order::count();will throw a exception:Phalcon\Mvc\Model\Exception: Column "ROWCOUNT" doesn't make part of the column map

i use PDO\Oracle driver

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@andresgutierrez
Copy link
Contributor

Can you please try again using Phalcon 2?

@andresgutierrez
Copy link
Contributor

This is fixed in the 2.0.x branch (Phalcon 2.0.4), you have to change a global ORM setting to allow unexpected columns:

\Phalcon\Mvc\Model::setup(['ignoreUnknownColumns' => true]);

@rlaffers
Copy link
Contributor

EDIT: I'm moving this into a separate issue. The listed exception was thrown only by my custom-patched Phalcon, please ignore it. Instead, the canonical 2.0.8 Phalcon prints no exception, but no results (which is an error).

Please reopen this bug. The referenced commit fixes it only partially. Even with ignoreUnknownColumns => true the exception is thrown when using columnMap() and I try to find() with the limit option and then calling toArray() on the result:

//...trimmed model Languages
public function columnMap() {
    return array(
        'ID_LANGUAGE' => 'id',
        'TITLE' => 'title',
        'CODE_2' => 'code_2',
        'CODE_3' => 'code_3',
        'LOCALE' => 'locale'
    );
}
// ...later in the code
$result = Languages::find(array('limit' => 2));      
echo '<pre>' . var_export($result->toArray(), 1) . '</pre>';  // throws Phalcon\Mvc\Model\Exception: Column 'PHALCON_RN' is not part of the column map

The DB used is Oracle 10g. Phalcon 2.0.8. Connection configuration is as follows:

    'database' => array(
        'adapter'     => 'Oracle',
        'host'        => 'orahost',
        'username'    => 'webuser1',
        'password'    => 'secretpswd',
        'dbname'      => 'monitor',
        'schema'      => 'COMMON',
        'options' => array(
            \PDO::ATTR_CASE => \PDO::CASE_UPPER
        ),
    ),

There are 2 workarounds:

  • If I don't specify columnMap() in the model, the exception goes away. That is not an option however, as I need to map column names which are UPPERCASE to lowercase model properties.
  • If I add
            'PHALCON_RN' => '__foo__',

to the columnMap then the exception goes away. These are just workarounds though, not acceptable solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants