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

DOCS SQLSelect::value() should be execute() #10280

Closed

Conversation

christopherdarling
Copy link
Contributor

No description provided.

@dhensby
Copy link
Contributor

dhensby commented Apr 13, 2022

Interesting, it looks like it should really be ->execute()->value() but this also means this bit of code is wrong 😬 https://github.com/silverstripe/silverstripe-framework/blob/4.10.4/src/ORM/Queries/SQLSelect.php#L587-L593

@christopherdarling
Copy link
Contributor Author

christopherdarling commented Apr 13, 2022

https://github.com/silverstripe/silverstripe-framework/blob/4/src/ORM/Queries/SQLSelect.php#L587-L593 looks alright to me line 593 is calling value on a Query instance

public function value()

@@ -31,7 +31,7 @@ $count = DB::query('SELECT COUNT(*) FROM "Member"')->value();

// Through SQLSelect abstraction layer.
$query = new SQLSelect();
$count = $query->setFrom('Member')->setSelect('COUNT(*)')->value();
$count = $query->setFrom('Member')->setSelect('COUNT(*)')->execute();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$count = $query->setFrom('Member')->setSelect('COUNT(*)')->execute();
$count = $query->setFrom('Member')->setSelect('COUNT(*)')->execute()->value();

SQLSelect::execute() returns a Query instance, from which you then get the value: https://api.silverstripe.org/4/SilverStripe/ORM/Queries/SQLSelect.html#method_execute

@GuySartorelli
Copy link
Member

GuySartorelli commented Jul 7, 2022

Note: This should not be merged here. I have started the process of migrating docs to a new repository so this PR should be closed and a new one should be created there.

@GuySartorelli
Copy link
Member

Closing due to inaction - feel free to reopen this in the developer-docs repo if it's bothering you.

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

Successfully merging this pull request may close these issues.

3 participants