public function __construct($host, $dbname, $user, $pass) { try { parent::__construct('mysql:host=' . $host . ';dbname=' . $dbname, $user, $pass); } catch (PDOException $e) { exit($e->getMessage()); } catch (Exception $e) { exit($e->getMessage()); } self::$instance = $this; }
<?php set_include_path(get_include_path() . PATH_SEPARATOR . TEMPLATEPATH . '-child/includes'); require_once 'Util.php'; require_once 'FlickrModel.php'; require_once 'News/DBO.php'; require_once 'functions.php'; require_once 'UCI/LDAP.php'; @define('POST_METADATA_WRITER', '_writer'); @define('POST_METADATA_LINK', '_link'); $db = new News_DBO('cwisdb2.cwis.uci.edu', 'wp-news', 'news', 'newsdotucidotedu'); //ucin_init(); $features = News_DBO::getInstance()->query("\n SELECT a.*\n FROM wp_posts AS a\n WHERE a.post_type LIKE 'features'\n AND a.post_status LIKE 'publish'\n AND a.post_date < '2013-08-20'\n ORDER BY a.post_date\n DESC\n LIMIT 0,10\n ")->fetchAll(PDO::FETCH_OBJ); foreach ($features as $feature) { $meta = News_DBO::getInstance()->query("\n SELECT a.*\n FROM wp_postmeta AS a\n WHERE a.post_id LIKE '" . $feature->ID . "'\n AND a.meta_key = 'content_author'\n ")->fetchObject(); $author = json_decode($meta->meta_value); Util::debug($author); }
function ucin_get_post_metas($post_id) { $metas = News_DBO::getInstance()->query("\n SELECT a.*\n FROM wp_postmeta AS a\n WHERE a.post_id LIKE '" . $post_id . "'\n AND a.meta_key IN ('post_flickr_image', 'featured_image', 'featured_video', 'ucitube', 'ucitube_location', 'related_links', 'content_author')\n ")->fetchAll(PDO::FETCH_OBJ); return $metas; }