CodeIgniter Query Builder and MySQL strict mode interoperability
0 reputation · 16 Feb 2023, 01:00 UTC
Measuring query latency in a CodeIgniter application that uses the Query Builder against MySQL requires clarifying the integration boundary between PHP escaping and database strict mode handling.
The Query Builder automatically escapes values passed to where, insert and update unless escaping is disabled or raw SQL is used. When MySQL runs with STRICT_TRANS_TABLES or STRICT_ALL_TABLES, escaping does not prevent data-type mismatches that can cause warnings or errors. Profiling indicates most query time is spent in the database driver prepare/execute cycle rather than PHP escaping logic. An unresolved decision is whether the Query Builder should automatically cast loose data types based on column definitions, and the behavior is not documented as guaranteed and varies between CodeIgniter 3.x and 4.x.
Does the Query Builder guarantee consistent type handling for loose values under strict SQL mode? Is automatic escaping sufficient to avoid data-type mismatch errors, or is explicit casting required at the application layer? How should bottleneck measurement distinguish PHP escaping overhead from database execution time across CodeIgniter 3.x and 4.x?