Closed skycyclone closed 1 year ago
What's more, I don't understand what the role of new RawSql() is. Even though I have roughly looked at the source file of RawSql, I still don't understand whether it is for security protection or to generate objects for the next reuse to improve efficiency??
Thank you for reporting.
RawSql
expresses raw SQL strings. That's all.
Normally, values passed to QueryBuilder are escaped, protected, DBPrefix-added, or otherwise manipulated.
RawSql ensures that no such processing occurs.
It does not provide any security protection. You must ensure it is safe by yourself.
I sent a PR to fix this: #7277
PHP Version
8.1
CodeIgniter4 Version
4.3.1
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
No response
What happened?
In Query Builder Class, if you use new RawSql() in $builder ->like(), and then use $builder ->countAllResults (FALSE); An error will be triggered when the total number of query results is obtained and then the query results are obtained.
Error prompt:
After debugging, it is found that if the countAllResults parameter is not set to FALSE, no error will be reported, but the subsequent get() cannot obtain the correct query results;
In addition, the third parameter of get() can also reset the query object. After setting, $builder ->countAllResults(); The same error is reported!
Problem conclusion: New RawSql() cannot be used in the link() before resetting values for SELECT; Or if you want to use new RawSql(), you cannot reset values for SELECTs??
Steps to Reproduce
or
Expected Output
Get the total number of query results and query result array normally
Anything else?
No response