dbDelta does not create Table, but returns success
The Problem was in this line: time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, I changed it to: time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, Now, it works.
The Problem was in this line: time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, I changed it to: time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, Now, it works.
Using $wpdb->insert and or related methods to modify data within any of the default WordPress tables, be it posts, postmeta, user, usermeta etc is discouraged because there are functions which already exist for the purpose of modififying data within those tables. For example, wp_insert_post wp_update_post wp_delete_post Database Queries Avoid touching the database directly. If there … Read more
If you want the query, that’ll be $wpdb->last_query (note that you also do not need SAVEQUERIES, that’s only if you want a log of every query ($wpdb->queries) last_error is… well, the error! Update: Possible explanation for last_error being empty – this is the source of wpdb::query(): // If we’re writing to the database, make sure … Read more
Couldn’t you just use PHP’s date() function? $prepared_date = date( ‘Y-m-d H:i:s’, $expires );
$wpdb doesn’t suit for fetching huge amount of data from database. Why? In your case: $wpdb->get_results( … ) – fetches all results into your RAM at once. It means if you have 4mb, 10mb, or 50mb of data in db, everything will be stored in memory (what is limited as you know). $wpdb->get_results( …, ARRAY_A … Read more
$wpdb-prepare works like sprintf and vsprintf. The first argument will always be a format string. The only acceptable format specifiers are %s and %d. Others I have never tested but may result in parse error as per the Codex. You must escape literal % in your query with %, e.g: %% If you use it … Read more
There is no way to automatically make wpdb do this. This is really a limitation of PHP that WordPress doesn’t happen to address. wpdb doesn’t have any hooks or actions that would help you either, so the best thing you can do is write your own wrapper function and run your queries through that so … Read more
As you can see in source code the = sign is hardcoded in the wpdb::update() method, so, by default, is not possible to use IN for update method. Simplest way to do the trick is to use the wpdb::query() with your sql query, just be sure to properly escape all values Example: function wpdb_update_in( $table, … Read more
Yes, they’re normal. They were added in 4.8.3 to fix an SQL injection vulnerability. You can read an article describing the technical reasons for this happening here and the ticket for the change here. The placeholder characters are replaced by the random characters on the last line of $wpdb->prepare() with the $wpdb->add_placeholder_escape() function, which calls … Read more
When $wpdb method doesn’t perform as it should it is likely issue with resulting SQL query (because of wrong input or something else). Follow wpdb reference in Codex for troubleshooting: enable database error display via $wpdb->show_errors() check what query is being formed and run via $wpdb->last_query