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

[update] ADD where RAW style #1003

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

[update] ADD where RAW style #1003

wants to merge 9 commits into from

Conversation

phpseven
Copy link

@phpseven phpseven commented Aug 16, 2021

before: when we use where RAW on SQL_FUNCTION(col_name), we must write whole condition in ONE RAW SQL,
now : You can write one condition in ONE RAW,

In other words, as long as there is an SQL method, all limit, order and group by must be written together. Not elegant

也就是说,之前只要带有一个sql的方法,那所有的LIMIT,ORDER,GROUP BY就都必须写在一起了,很难看

$data = $database->select('account', [
'user_id',
'email'
],
Medoo::raw('WHERE
LENGTH(<user_name>) > 5
ORDER BY RAND()
LIMIT 10
')
);

now you can write it like

$this->database->select(
"account",
"user_name",
[
Medoo::raw("ROUND(<float_val>) = :round_value", [':round_value'=>10]),
'LIMIT' => [20, 100],
"ORDER" => "user_id",
]
);

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.

1 participant