I'm having some difficulties understanding the errors when using sprintf.
Current query is:
$sql = sprintf('SELECT *
FROM %s
INNER JOIN %s a ON (a.user_id = created_by)
LEFT JOIN %s b ON (b.user_id = modified_by)
WHERE provider_name LIKE "%%?%%"
LIMIT ?,?', TABLE_NAME1, TABLE_NAME2, TABLE_NAME3);
$q = $this->db->query($sql, array($q, $page['si'], (int)$offset));
The error occurs on this line: WHERE provider_name LIKE "%%?%%"
I've tried changing it many times using the following:
- WHERE provider_name LIKE "%%%?%%%"
- WHERE provider_name LIKE "%?%"
- WHERE provider_name LIKE %%?%%
- WHERE provider_name LIKE %%%?%%%
I still get errors..
Errors:
A PHP Error was encountered
Severity: Warning
Message: sprintf(): Too few arguments
=====================================
A PHP Error was encountered
Severity: 4096
Message: Object of class CI_DB_mysql_result could not be converted to string
Filename: database/DB_driver.php
Line Number: 604
How should I perform this properly using sprintf?
Note: I'm using codeigniter so I'm using ? for querying.