Query in CodeIgniter:
$this->db->select('comments.created_at, comments.section_id, comments.submittedby_id, users.username, comments.text, sections.name');
$this->db->order_by('comments.created_at', 'desc');
$this->db->where('comments.submittedby_id', 'users.user_id');
$this->db->where('comments.section_id', 'sections.id');
$query = $this->db->get(array('comments', 'users', 'sections'),10);
Produce SQL Request:
SELECT
pdb_comments.created_at,pdb_comments.section_id,pdb_comments.submittedby_id,pdb_users.username,pdb_comments.text,pdb_sections.nameFROM (pdb_comments,pdb_users,pdb_sections) WHEREpdb_comments.submittedby_id= 'users.user_id' ANDpdb_comments.section_id= 'sections.id' ORDER BYpdb_comments.created_atdesc LIMIT 10
Sorun veritabanı öneki (pdb_) WHERE fıkrasında katma almaz olmasıdır. Ben elle $this->db->dbprefix ekleyerek önek ekleyebilirsiniz, ancak bu ana sorunu çözmek değil.
Quotes:
`pdb_comments`.`submittedby_id` = 'pdb_users.user_id'
Sağ tarafta tırnak doğru değildir, ve benim için 0 sonuç üretir. CodeIgniter benim masaya bir parça olarak nerede fıkra ikinci yarısını tanıması için herhangi bir yolu var mı; böylece veritabanı öneki ekleyerek, ve düzgün iki katılır kaçınarak tırnak yerleştirerek? Bunun başka bir yolu var mı? Şimdiden teşekkürler.
-
Jon