Я написал код ниже, который, как я думаю, представляет собой простой выбор с объединением.
$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
Попытка кодирования построителя запросов CodeIgniter с помощью join() отображает непреднамеренный запрос ⇐ Php
Кемеровские программисты php общаются здесь
1763338628
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
Подробнее здесь: [url]https://stackoverflow.com/questions/22009206/codeigniter-query-builder-coding-attempt-with-join-renders-an-unintended-query[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия