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

Postgresql lastinsertid #45

Merged
merged 5 commits into from
Sep 26, 2012

Conversation

geelweb
Copy link

@geelweb geelweb commented Sep 26, 2012

Hi,

a little patch to improve PostgreSQL compatibility, PDO::lastInsertID() requires the name parameter when used with PDO_PGSQL so I replaced calls like Yiii::app()->db->getLastInsertID(); by Yii::app()->db->getCommandBuilder()->getLastInsertID('{{tablename}}'

I also updated the user_groups insert query in User_groups::addGroup() method to remove the "`" character around the column names, not PostgreSQL compliant

…d column names and using Yii CDbCommandBuilder::getLastInsertID()
…nsertId the parameter "name" which is required by the PDO_PGSQL adapter
@c-schmitz
Copy link
Contributor

Thank you very much . Your changes look great. Please note that if you provide future patches please stick to our Standard for git commit messages here: http://docs.limesurvey.org/Standard+for+Git+commit+messages&structure=LimeSurvey+development

Thank you again! Great patch!

@c-schmitz
Copy link
Contributor

Oh, can you check on it again (because I cannot automatically merge it) and resubmit?

…d column names and using Yii CDbCommandBuilder::getLastInsertID()
…nsertId the parameter "name" which is required by the PDO_PGSQL adapter
@geelweb
Copy link
Author

geelweb commented Sep 26, 2012

Just rebased the branch with an updated master. You should be able to merge.

I'll read your Standard for my next commit messages, thanks for the link.

c-schmitz added a commit that referenced this pull request Sep 26, 2012
Fixed issue: Several errors in administration when using Postgres DB
@c-schmitz c-schmitz merged commit ec72e3c into LimeSurvey:master Sep 26, 2012
@Holzhauer
Copy link

I had problems importing groups and their questions by .lsg files. Groups got inserted but questions where assigned gid=0 and thus did not appear. I found that

Yii::apps()->db->getCommandBuilder()->getLastInsertID('{{groups}}');

returns 0. However,

Yii::app()->db->getLastInsertID('{{groups}}');

yields the correct gid. I don't know what the use of getCommandBuilder() is...

BTW: I'm using PHP 5.4.7 and MySQL 5.5.25

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