$wpdb->подготовка по вложенному запросу SelectPhp

Кемеровские программисты php общаются здесь
Anonymous
$wpdb->подготовка по вложенному запросу Select

Сообщение Anonymous »


I'm strugling with a nested SELECT query that I want to prepare.

$sql = $wpdb->prepare("SELECT (SELECT Level FROM $bodyReaction WHERE UserID = %d ORDER BY Date DESC LIMIT 1, $currentUserId) AS BodyReaction, (SELECT Level FROM $eyeToHand WHERE UserID = %d ORDER BY Date DESC LIMIT 1, $currentUserId) AS EyeToHand, (SELECT Level FROM $highJump WHERE UserID = %d ORDER BY Date DESC LIMIT 1, $currentUserId) AS HighJump, (SELECT Level FROM $legCoordination WHERE UserID = %d ORDER BY Date DESC LIMIT 1, $currentUserId) AS LegCoordination, (SELECT Level FROM $longJump WHERE UserID = %d ORDER BY Date DESC LIMIT 1, $currentUserId) AS LongJump, (SELECT Level FROM $sideToSide WHERE UserID = %d ORDER BY Date DESC LIMIT 1, $currentUserId) AS SideToSideJump "); $result = $wpdb->get_row( $sql, ARRAY_N );

So the result should be an associative array with named keys and the data from the 5 tables (latest Level).

I've checked the $sql and it is empty. I've checked the $wpdb->last_error and it doesn't throw an error.

I've created the query without the prepare code and it works fine. Can anyone suggest how to fix the code.

Thanks Flemming


Источник: https://stackoverflow.com/questions/780 ... lect-query

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