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

BUG. PHQL error while only inserting to table with 2 columns #2019

Closed
etilley opened this issue Feb 10, 2014 · 3 comments
Closed

BUG. PHQL error while only inserting to table with 2 columns #2019

etilley opened this issue Feb 10, 2014 · 3 comments
Labels
bug A bug report status: medium Medium

Comments

@etilley
Copy link

etilley commented Feb 10, 2014

I have a table in my database that has 2 columns in it. First column is the id and the second one is the name. if i try to run

$this->modelsManager->executeQuery('INSERT INTO ModelName (column_name) VALUES (\'test\')');

I will get "Unknown expression" but if I do

$this->modelsManager->executeQuery('INSERT INTO ModelName (id, column_name) VALUES ( \'\'  \'test\')');

it will add the row. I added an extra column to the table for test and it would add the row without me specifying the id column.

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

@mywebcontent
Copy link

Hello,

I have the same issue, I solved with something like this:

$this->modelsManager->executeQuery("INSERT INTO Featured (id,articleid) VALUES (:id:,:articleid:)",array('id' => NULL,'articleid' => $value[$i]));

although it's not a beautiful solution.
It seems that PHQL runs into trouble if trying to insert a record into a table with only an id and one another columns. You can try a solution like this:

$featured=new Featured();
$featured->articleid=$value[$i];
$featured->save();

maxgalbu added a commit to maxgalbu/cphalcon that referenced this issue Apr 12, 2014
phalcon pushed a commit that referenced this issue Apr 12, 2014
@Green-Cat
Copy link
Contributor

@andresgutierrez fixed in #2328

@phalcon phalcon closed this as completed May 25, 2015
@maxgalbu
Copy link
Contributor

It's probably not fixed on 2.0, but I didn't check

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

5 participants