/** * Returns an array of objects (as returned by $wpdb->get_results()) of this user's recent posts. * * @param int $count Amount of rows to return. * @return ObjectArray */ public function getRecentPosts($count = 15, $order = 'DESC') { $wpdb = ThinkUpWordPressPlugin::getDatabaseConnection(); $options_array = ThinkUpWordPressPlugin::getOptionsArray(); // database may be on same server but not same db as wordpress $db = $wpdb->escape($options_array['thinkup_db']['value']); $prefix = $options_array['thinkup_table_prefix']['value']; if ($count >= 0) { $sql = $wpdb->prepare("\n SELECT *\n FROM {$db}." . $prefix . "posts\n WHERE author_username='******'\n AND in_reply_to_user_id is null\n AND network='%s'\n ORDER BY pub_date {$wpdb->escape($order)}\n LIMIT %d", $this->username, $this->network, $count); } else { $sql = $wpdb->prepare("\n SELECT *\n FROM {$db}." . $prefix . "posts\n WHERE author_username='******'\n AND in_reply_to_user_id is null\n AND network='%s'\n ORDER BY pub_date {$wpdb->escape($order)}", $this->username, $this->network); } return $wpdb->get_results($sql); }
/** * Return an object (as returned by $wpdb->get_row()) of this post's database record. * * @return Object Post's database record. */ public function getPostInfo() { if (!isset($this->post_info)) { $wpdb = ThinkUpWordPressPlugin::getDatabaseConnection(); if (!isset($this->get_post_info_sql)) { $options_array = ThinkUpWordPressPlugin::getOptionsArray(); // database may be on same server but not same db as wordpress $db = $wpdb->escape($options_array['thinkup_db']['value']); $prefix = $options_array['thinkup_table_prefix']['value']; $this->get_post_info_sql = $wpdb->prepare(" SELECT * FROM `$db`.`".$prefix."posts` WHERE post_id = {$wpdb->escape($this->post_id)} AND network = %s;", $this->network); } $this->post_info = $wpdb->get_row($this->get_post_info_sql); } return $this->post_info; }