Activation hook not creating table

The table name needs to be in quotes on the line where you’re checking if it exists. I tested it, and after that was fixed, the table was successfully created. Here is the full code: function mm_booking_activate() { global $wpdb; $mm_booking_table_name = $wpdb->prefix . “mm_booking”; $mm_booking_db_version = ‘1.0’; $charset_collate = $wpdb->get_charset_collate(); if ( $wpdb->get_var( “SHOW … Read more

Importing MariaDB into Mysql in WordPress

While at the current point in time there is very little difference, and maybe no difference at all, this is a bad practice if your development environment supposed to replicate the server your code will run on. There is just no point in forking a product without having the intention to change it, and the … Read more

Passing array of strings to a SQL statement in a WordPress plugin

$wpdb->prepare() accepts a single array of arguments as the second parameter, e.g. $wpdb->prepare( “SELECT * FROM table WHERE field1 = %s AND field2 = %d AND field3 = %s”, array( ‘foo-bar’, 123, ‘[email protected]’ ) ) Therefore you can use an array of placeholders with the SQL command (the 1st parameter), like so: // Create an … Read more

sql query to put quotes around numbers in img tag

You are simply going to love this one First of all, here is a sample table with data loaded: mysql> use junk Database changed mysql> drop table todd; Query OK, 0 rows affected (0.01 sec) mysql> create table todd (id int not null auto_increment,url VARCHAR(255), -> primary key (id)) ENGINE=MyISAM; Query OK, 0 rows affected … Read more

Database slowdown after update to 3.4.1

If you’ve got 60,000 records, try cleaning post/page revisions; these really accumulate and cause excessively long queries. I’ve seen database sizes drop 90% with huge increases in performance. Run the query below in phpmyadmin or from the command line and then optimize: DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) … Read more

Query All users that has post

add this in your arguments ‘query_id’ => ‘authors_with_posts’, $user_args = array( ‘role’ => ‘frontend_vendor’, ‘orderby’ => ‘display_name’, ‘query_id’ => ‘authors_with_posts’, ‘order’ => ‘ASC’, ‘number’ => $no, ‘offset’ => $offset );