I have been looking into moving my one of my sites from CI2 to 3 and hit a snag that I have been unable to track down. This code:
PHP Code:
$this->db->start_cache();
$this->db->select( 'molecule.idmolecule,molecule,comment, molecule.projects_id');
$this->db->where( 'projects_id', $this->project_id );
$this->db->from( 'molecule' );
$this->db->order_by( 'molecule', 'ASC' );
$query = $this->db->get_compiled_select();
print_r($query);
$this->db->flush_cache();
Returns this query which appears to me to be correct:
SELECT `molecule`.`idmolecule`, `molecule`, `comment`, `molecule`.`projects_id` FROM `molecule` WHERE `projects_id` = 7
If but it also returns this error even when I place a die; immediately after print:
A Database Error Occurred
Error Number: 1054
Unknown column 'projects_id' in 'where clause'
UPDATE `ci_sessions` SET `timestamp` = 1424579236 WHERE `projects_id` = 7 AND `id` = '51ae29260b86c80abe0c60829071d14727c66bdb'
Filename: libraries/Session/drivers/Session_database_driver.php
Line Number: 239
This is coming from both the WHERE and the ORDER_BY lines. Removing both returns the data I expect. That 'id' in the database error block is the session id. Is this a bug or did I miss something???
Edit:
I did not have enough of the code pasted originally. I have traced the WHERE and ORDER_BY problem to having the start_cache and flush_cache lines.