-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I think, there is an issue with SQLite database abstraction layer. I encountered this issue in my GutenDraw plugin recently.
If we call this SQL below 'P.id' transforms to 'ID' in array output. The problem only affects the ID column.
global $wpdb;
$sql = "SELECT P.id, P.post_title FROM {$wpdb->posts} AS P";
$results = $wpdb->get_results($sql, 'ARRAY_A');
foreach ($results as $item) {
foreach ($item as $key => $value) {
echo $key . ': ' . $value . ' ';
}
echo '<br>';
}output
ID: 1 post_title: Hello world!
ID: 2 post_title: Sample Page
ID: 3 post_title: Privacy Policy
ID: 4 post_title: Auto Draft
ID: 5 post_title: TESTas result, we can't use such code, because it's empty
echo $item['id'];To solve this problem, I had to change all the selects to this option, and hard-code the names for the columns, where 'id' is in lower case.
$sql = "SELECT P.id as id, P.post_title FROM {$wpdb->posts} AS P";Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels