У меня есть запрос, который извлекает значения из нескольких таблиц. Я хочу заказать их с помощью show_date ASC, только я не могу заставить его выводить какие-либо данные. Может ли кто-нибудь увидеть проблему с моим синтаксисом?PHP Запрос неверно возвращает данные
$artists = $wpdb->get_results("SELECT * FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_SHOWS . " AS s, ORDER BY s.show_date ");
var_dump($artists);
foreach($artists as $artist_group)
{
$shows = $wpdb->get_results("SELECT *
FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_VENUES . " as v, " . GIGPRESS_SHOWS ." AS s
LEFT JOIN " . GIGPRESS_TOURS . " AS t
ON s.show_tour_id = t.tour_id
WHERE " . $date_condition . "
AND show_status != 'deleted' AND s.show_artist_id = " . $artist_group->artist_id . "
AND s.show_artist_id = a.artist_id AND s.show_venue_id = v.venue_id " . $further_where . "
ORDER BY s.show_date " . $sort . ",s.show_expire " . $sort . ",s.show_time ". $sort . $limit);
}
СБРОСА ВОЗВРАТ
массив (72) {[0] => объект (StdClass) # 260 (25) {[ "artist_id"] => строка (1) "1" ["artist_name"] => string (14) "Damien Dempsey" ["artist_order"] => string (1) "0" ["show_id"] => string (1) "1" ["show_artist_id"] => string (1) "1" ["show_venue_id"] => string (1) "1" ["show_tour_id"] => string (1) "0" ["show_date"] => string (10) "2012-01 -29 "[" show_multi "] => string (1)" 0 "[" show_time "] => string (8)" 20:30:00 "[" show_expire "] => string (10)" 2012-01 -29 "[" show_price "] => string (7)" £ 10.00 "[" show_tix_url "] => string (0)" "[" show_tix_phone "] => string (0)" "[" show_ages "] = > string (8) "All Ages" ["show_notes"] => string (0) "" ["show_related"] => string (1) "0" ["show_status"] => string (7) "deleted" [ "show_tour_restore"] => string (1) "0" ["show_address"] => NULL ["show_locale"] => NULL ["show_country"] => NULL ["show_venue"] => NULL ["show_venue_url"] => NULL ["show_venue_phone"] => NULL} [1] => object (stdClass) # 259 (25) {["artist_id"] => string (1) "2" ["artist_name"] => string (10) «Gary Dunne» ["artist_order"] => string (1) "0" ["show_id"] => string (1) "1" ["show_artist_id"] => string (1) "1" [" show_venue_id "] => string (1)" 1 "[" show_tour_id "] => string (1)" 0 "[" show_date "] => string (10)" 2012-01-29 "[" show_multi "] = > string (1) "0" ["show_time"] => string (8) "20:30:00" ["show_expire"] => string (10) "2012-01-29" ["show_price"] = > строка (7) "£ 10.00" ["show_tix_url"] => строка (0) "" ["show_tix_phone"] => строка (0) "" ["show_ages"] => строка (8) "Все возрасты" ["show_notes"] => string (0) "" ["show_related"] => string (1) "0" ["show_status"] => string (7) "deleted" ["show_tour_restore"] => string (1) «0» [«show_address»] => NULL ["show_locale"] => NULL ["show_country"] => NULL ["show_venue"] => NULL ["show_venue_url"] => NULL ["show_venue_phone"] => NULL} [2] => object (stdClass) # 261 (25) {["artist_id"] => string (1) "3" ["artist_name"] => string (19) "London Irish Center" [ "artist_order"] => string (1) "0" ["show_id"] => string (1) "1" ["show_artist_id"] => string (1) "1" ["show_venue_id"] => string (1) "1" ["show_tour_id"] => string (1) "0" ["show_date"] => string (10) "2012-01-29" ["show_multi"] => string (1) "0 "[" show_time "] => string (8)" 20:30:00 "[" show_expire "] => string (10)" 2012-01-29 "[" show_price "] => string (7)" £ 10.00" [ "show_tix_url"] => строка (0) "" [ "show_tix_phone"] => строка (0) "" [ "show_ages"] => строка (8) "всех возрастов"
Ive попробовал следующее:
foreach($artists as $artist_group) {
$shows = $wpdb->get_results("SELECT * FROM " . GIGPRESS_ARTISTS . " AS a, " . GIGPRESS_VENUES . " as v, " . GIGPRESS_SHOWS ." AS s LEFT JOIN " . GIGPRESS_TOURS . " AS t ON s.show_tour_id = t.tour_id WHERE " . $date_condition . " AND show_status != 'deleted' ORDER BY s.show_date ASC " . $limit);
Который работает в отношении упорядочения, но он выводит каждое значение примерно в 100 раз или что-то глупое ..
Что возвращает ваш 'var_dump()'? – zerkms
Какое сообщение об ошибке? var_dump цикл foreach. –
У вас есть успешная связь? – ngen