Hints for new features for INSERT
Hello @wolfy-j ,
just a simple suggestion as it's a feature I implemented many times:
- add IGNORE for INSERT (just need a boolean like SelectQuery::distinct)
- add the ability to compile this type of query
INSERT INTO table (username, email) SELECT username, email FROM other_table WHERE....with a new methodInsertQuery::select(SelectQuery $select)and building the last part of the INSERT statement with the compiled SELECT statement.
kind regards, maks
unrelated
- You can use self as a return type for any
public function fluentMethod(): self - In php-do blocks it's usually better to use
@return $thisif the return value is the same instance (and not for instance a clone)
All accepted. Injecting SELECT into INSERT is not a problem, we already have such capability on VALUE level.
We will implement this feature somewhere in a future milestone.
Hello @wolfy-j ,
All accepted. Injecting SELECT into INSERT is not a problem, we already have such capability on VALUE level.
but the compiler have this hardcoded string format:
'INSERT INTO %s (%s) VALUES %s',
we need a more flexible format (like selectQuery) to allow:
INSERT{ IGNORE} INTO table{ column_list(...)} {VALUES source_values(...)|SELECT FROM...}
- the column_list(...) fragment should be optional, even in not INSERT...SELECT statements
- the last part should allow both (mutually excluding) VALUES and SELECT statements
kind regards
Hi, I meant to say that your suggestion was accepted :) It's pretty easy to change the compiler since all the tokens are isolated.
I would appreciate any PR, if not - this feature will be revised in future releases.