How to add/change a value of $wpdb property/var?

There is a problem: I want to add a table ‘linkmeta’ to work like ‘postmeta’ or ‘commentmeta’.. and use functions like add_metadata / update_metadata / delete_metadata! but, in this functions call “_get_meta_table()” to verify the name in db, this code: function _get_meta_table($type) { global $wpdb; $table_name = $type . ‘meta’; if ( empty($wpdb->$table_name) ) return … Read more

get posts and postmetas in assoc array

how do I get all posts and postmetas in an associative array? $allposts = $wpdb->get_results(” SELECT $wpdb->posts.post_title, $wpdb->postmeta.meta_key FROM $wpdb->posts JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.id WHERE $wpdb->posts.post_type=”post” AND $wpdb->posts.post_status=”publish”;”, OBJECT_K); I just don’t get it…. 1 Answer 1 Basically, you can’t do it in a single SQL query. You need two. You don’t have … Read more

Query WP data with the WPDB API from outside WordPress

I’m working on a project with WP, a bit like a plugin, but not quite one. I’m encountering an issue, when trying to include a file that contains some custom SQL functions in a class, in a completely different file, I get redirected to http://example.com/folder1/file.php/wp-admin/install.php Which states that I’ve already installed WP and I need … Read more

How to check for empty and not a failure

I’m querying the postmeta table to see if a url has already been entered, using this statement (where $thisLink is the url I’m checking) $mypostids = $wpdb->get_results(“select * from $wpdb->postmeta where meta_key = ‘rssmi_source_link’ and meta_value like ‘%”.$thisLink.”%'”); The problem is that on some servers it appears it’s not finding urls that already exist in … Read more

$wpdb insert array

I need to insert multiple array. I get error: mysql_real_escape_string() expects parameter 1 to be string, array given My example code: $array_info is Array ( [0] => Array ( [0] => a [1] => b [2] => c ) [1] => Array ( [0] => d [1] => e [2] => f ) ) $data … Read more