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

No way to do SELECT FOR UPDATE via ActiveRecord::find() #11570

Closed
Lexxtor opened this issue May 15, 2016 · 4 comments
Closed

No way to do SELECT FOR UPDATE via ActiveRecord::find() #11570

Lexxtor opened this issue May 15, 2016 · 4 comments
Labels

Comments

@Lexxtor
Copy link

Lexxtor commented May 15, 2016

I want to do query like:
SELECT * FROM table FOR UPDATE
Via:

table::find()
  ->postFix('FOR UPDATE')
  ->all();
Q A
Yii version 2.0.8-dev
@yii-bot
Copy link

yii-bot commented May 15, 2016

This is an automated comment, triggered by adding the label question.

Please note, that the GitHub Issue Tracker is for bug reports and feature requests only.

We are happy to help you on the support forum, on IRC (#yii on freenode), or Gitter.

Please use one of the above mentioned resources to discuss the problem.
If the result of the discussion turns out that there really is a bug in the framework, feel free to
come back and provide information on how to reproduce the issue. This issue will be closed for now.

@SilverFire
Copy link
Member

You probably need something like

    $sql = Type::find()->createCommand()->getRawSql();
    Yii::$app->db->createCommand($sql . ' FOR UPDATE')->execute();

@Lexxtor
Copy link
Author

Lexxtor commented May 16, 2016

@SilverFire I know that, but I want to get array of ActiveRecord`s in a nice short way, like:

table::find()->all();

but with FOR UPDATE statement.

@SilverFire
Copy link
Member

Currently it is not possible

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

No branches or pull requests

3 participants