Попытка кодирования построителя запросов CodeIgniter с помощью join() отображает непреднамеренный запросPhp

Кемеровские программисты php общаются здесь
Anonymous
Попытка кодирования построителя запросов CodeIgniter с помощью join() отображает непреднамеренный запрос

Сообщение Anonymous »

Я написал код ниже, который, как я думаю, представляет собой простой выбор с объединением.
$this->db->select('
PAS_User.user_first_name,
PAS_User.user_last_name,
PAS_User.user_avatar_url,
AMS_Notification.noti_entitiy_id,
AMS_Notification.noti_entity_type,
AMS_Notification.noti_updated
FROM AMS_Notification
INNER JOIN PAS_User ON AMS_Notification.noti_from_user_id = PAS_User.user_user_id
');
$this->db->from('AMS_Notification');
$this->db->join('PAS_User', 'PAS_User ON AMS_Notification.noti_from_user_id = PAS_User.user_user_id');
$this->db->where('AMS_Notification.noti_to_user_id', $userid);
$this->db->order_by("noti_updated", "desc");
$query = $this->db->get('AMS_Notification');

if ($query -> num_rows() == 1) {
return $query->result();
} else {
return false;
}

Однако, когда я вызываю страницу, она показывает этот запрос с двумя инструкциями FROM. Может ли кто-нибудь сказать мне, что я здесь делаю не так?
SELECT
`PAS_User`.`user_first_name`,
`PAS_User`.`user_last_name`,
`PAS_User`.`user_avatar_url`,
`AMS_Notification`.`noti_entitiy_id`,
`AMS_Notification`.`noti_entity_type`,
`AMS_Notification`.`noti_updated`
FROM AMS_Notification
INNER JOIN PAS_User ON AMS_Notification.noti_from_user_id = PAS_User.user_user_id
FROM (`AMS_Notification`, `AMS_Notification`)
JOIN `PAS_User` ON `PAS_User` `ON` AMS_Notification.noti_from_user_id = PAS_User.user_user_id
WHERE `AMS_Notification`.`noti_to_user_id` = '7'
ORDER BY `noti_updated` desc


Подробнее здесь: https://stackoverflow.com/questions/220 ... nded-query

Вернуться в «Php»