-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
model->findFirstBy... doesn't work with columnMap() in Oracle #10490
Comments
Please submit model code? |
I have fixed it by adding 'PHALCON_RN' => 'phalcon_rn', into the columnMap(). But this should be done at core level. getDI()->get('db')->lastInsertId($this->getSequenceName()); } public function getSource() { return "USERS"; } public function columnMap() { return array( 'USERID' => 'userid', 'NAME' => 'name', 'PHONE' => 'phone', 'EMAIL' => 'email', 'PASSWORD' => 'password', 'MUSTCHANGEPASSWORD' => 'mustChangePassword', 'PROFILESID' => 'profilesId', 'SEX' => 'sex', 'BIRTHDATE' => 'birthdate', 'PHALCON_RN' => 'phalcon_rn', ); } public function initialize() { $this->skipAttributesOnCreate( array('USERID') ); } } |
Fields should case sensitive. |
Sorry, I do not understand how to apply your answer, would you elaborate? |
Column name is |
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]); |
Cool, thank you |
Hi,
Phalcon 2.0.2, Oracle 12c.
I have set columnMap() for my model.
Then, I invoke find on my model like this:
Users::findFirstByEmail('test@test.com');
In SQL debug.log I see:
[Tue, 09 Jun 15 02:58:38 +0300][INFO] SELECT COUNT() "numrows" FROM (SELECT * FROM (SELECT Z1., ROWNUM PHALCON_RN FROM (SELECT USERS.USERID, USERS.NAME, USERS.EMAIL, USERS.PASSWORD, USERS.MUSTCHANGEPASSWORD, USERS.PROFILESID, USERS.SEX, USERS.PHONE, USERS.BIRTHDATE FROM USERS WHERE USERS.EMAIL = :0) Z1 WHERE ROWNUM <= 1))
But the call itself results in error:
Column 'PHALCON_RN' doesn't make part of the column map
#0 [internal function]: Phalcon\Mvc\Model::cloneResultMap(Object(Vokuro\Models\Users), Array, Array, 0, false)
#1 [internal function]: Phalcon\Mvc\Model\Resultset\Simple->current()
#2 [internal function]: Phalcon\Mvc\Model\Resultset->getFirst()
#3 [internal function]: Phalcon\Mvc\Model\Query->execute(Array, NULL)
#4 [internal function]: Phalcon\Mvc\Model::findFirst(Array)
#5 /home/var/www/html/v1/app/controllers/UsersController.php(93): Phalcon\Mvc\Model::__callStatic('findFirstByEmai...', Array)
#6 /home/var/www/html/v1/app/controllers/UsersController.php(93): Vokuro\Models\Users::findFirstByEmail('test@test.ru')
#7 [internal function]: Vokuro\Controllers\UsersController->createAction()
#8 [internal function]: Phalcon\Dispatcher->dispatch()
#9 /home/var/www/html/v1/public/index.php(41): Phalcon\Mvc\Application->handle()
How this bug can be fixed?
The text was updated successfully, but these errors were encountered: