SQL, PHP 및 CI를 배우면서 아직 나와 함께하지 마십시오.올바른 'Codeigniter way'에서이 SQL 쿼리를 작성하려면 어떻게해야합니까?
현재 Codeigniter가 만료되었으며 다음과 같이 모델 내에 쿼리가 있습니다.
function retrieve_user($user_id)
{
// TODO: Update this query to correct CI syntax
$query = "SELECT user_id, username, email, banned, created, avatar, country, gender, user_level FROM users, user_profiles WHERE users.id = user_profiles.id AND users.id = ?";
$values = array($user_id);
return $this->db->query($query, $values)->row_array();
}
좋은 결과를 얻었지만 좋은 결과를 얻을 수 있었지만 문서화 된 CI 형식을 사용하여 이것을 작성하고 싶습니다.
아무도 도와 줄 수 있습니까?
$this->db->select('user_id, username, email, banned, created, avatar, country, gender, user_level');
$this->db->from('users');
$this->db->join('user_profiles', 'user_profiles.id = users.id');
$this->db->where('users.id =', 'user_profiles.id');
$this->db->where('users.id =', '?');
시도 자세한 내용이 다음과 같이하십시오 : http://www.codeigniter.com/user_guide/database/active_record.html
고맙습니다. –
Gordon_에 오신 것을 환영합니다. – Feroz