У меня проблемы с объединением двух запросов Activerecord вместе. Неправильный код отображает то, что на самом деле работает, и прокомментированный код отображает то, что я считаю кодом. Очевидно, что прокомментированный код должен быть в цикле. < /P>
$musicQuery = "album1,album2,album3,album4");
$albums = explode(",", $musicQuery);
foreach($albums as $i => $album) {
$albumQuery = $this->db->get_where('albums', array('id' => $album), 1)->row_array();
$artistQuery = $this->db->get_where('artists', array('tc_id' => $albumQuery['artist']), 1)->row_array();
echo $artistQuery['artist'].'
';
}
// This is what I thought I would need
//$this->db->select('*');
//$this->db->from('albums');
//$this->db->join('artists', 'artists.id = albums.artist');
//$this->db->where('id', $album);
//$this->db->limit(1);
//$this->db->order_by("post_views", "desc");
//$artistQuery = $this->db->get();
Подробнее здесь: https://stackoverflow.com/questions/199 ... ters-query