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
Add a new method SQLite3Stmt::getSQL returning the SQL query used in the statement #3669
Conversation
@bohwaz I'd prefer to separate factoring out |
Sure will do that when I have some time. |
return; | ||
} | ||
|
||
SQLITE3_CHECK_INITIALIZED(stmt_obj->db_obj, stmt_obj->initialised, SQLite3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong (as in several other places of the existing code as well). We' re mixing the initialization check of SQLite3
and SQLite3Stmt
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copy-pasted existing code here yeah, what would you suggest instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure (yet) what's the proper way to do it. Frankly, I'd rather wish that we didn't have to do these initialization checks at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Just tell me if I need to change anything to my patch :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I think it's fine to leave this for now, and to review all those checks later. :)
That PR has now been merged into this one. |
ext/sqlite3/sqlite3.c
Outdated
#endif | ||
} | ||
else | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this file (mostly) uses K&R style, so I think it's best to stick with it. I.e. write the 3 lines above as a single line:
} else {
Since PR #3702 has been applied, this PR has conflicts now. Could you please rebase? Generally, I'm fine with the addition of this method. Thanks! |
…t SQL, eventually expanded
9571cd3
to
9247df1
Compare
Yup, rebased, also resolved the else indentation issue, thanks. Is there some kind of codesniffer for PHP C code so that I avoid that in the future? |
No, unfortunately not (yet). If there are no objections, I'll apply this PR on the next weekend (i.e. in a week). |
Thanks, @bohwaz! Applied as 82af24f. Note that I have unindented the preprocessor instructions according to our coding standards (missed this earlier). PS: Documented. |
::getSQL(true)
will return the expanded SQL query (binded parameters replaced, "as" the query will be executed by SQL, eg.SELECT * FROM table WHERE a = 42;
) but is only available with SQLite >= 3.14 (iftrue
parameter is passed with an old version of SQLite the method will return an error)while
::getSQL(false)
(also the default) will just return the SQL query with the binded parameters as-is (eg.SELECT * FROM table WHERE a = :param;
)