Problem in inserting row to custom database table

The simplest thing to do here is remove the: ‘id’ => “”, from the data array. Also, to simplify your database creation, you don’t need to do your get_var(), you can just change your SQL command to: CREATE TABLE IF NOT EXISTS $table_name This way you let the db handle creation of the table without … Read more

Database query works fine outside WordPress

After struggling with different functions , I figure out $wpdb->get_row() and $wpdb->get_var()The first one returns rows into an associative array or numerical array , depends on the second argument in $wpdb->get_row(‘query’,ARRAY_A or ARRAY_N or OBJEECT) and the second one that I used to solve my problem return only one variable from particular table.e.g, <?php $user_count … Read more

How can I combine one field using wpdb and group by?

Got it working with $uvusql = $wpdb->prepare( ” SELECT p.ID, p.post_title, p.post_date, wcom.order_item_name, wcomm.meta_key, wcomm.meta_value, wcomm2.meta_key AS meta_key_qty, wcomm2.meta_value AS meta_value_qty, pm2.meta_value AS meta_value_location FROM $wpdb->posts AS p INNER JOIN $wpdb->postmeta AS pm ON p.ID = pm.post_id INNER JOIN $wpdb->woocommerce_order_items AS wcom ON p.ID = wcom.order_id INNER JOIN $wpdb->woocommerce_order_itemmeta AS wcomm ON wcom.order_item_id = wcomm.order_item_id … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)