function save($ex_post_id) { global $wpdb; $ex_exhibit_id = $_POST['exhibitid']; if ($ex_exhibit_id != null) { // See if the association already exists $table = WpExhibitConfig::table_name(WpExhibitConfig::$EXHIBITS_ASSOC_TABLE_KEY); $assoc = $wpdb->get_row("SELECT * FROM {$table} WHERE postid = {$ex_post_id} ;", ARRAY_A); if ($assoc === false) { } else { if ($assoc === 0 || !$assoc) { // There wasn't an association. Add a new one $assoc = $wpdb->query("INSERT INTO {$table} (postid, exhibitid) VALUES ({$ex_post_id}, {$ex_exhibit_id}) ;", ARRAY_A); } else { // There was an association. Upate it $assoc = $wpdb->query("UPDATE {$table} SET postid = {$ex_post_id}, exhibitid = {$ex_exhibit_id} WHERE postid = {$ex_post_id} ;", ARRAY_A); } } // $ex_exhibit = new WpPostExhibit(); // $ex_success = DbMethods::loadFromDatabase($ex_exhibit, $ex_exhibit_id); // if ($ex_success == true) { // // Create a new one // $ex_exhibit->set('postid', $ex_post_id); // } // $ex_exhibit->save(); } }
function is_parrotable($url) { global $wpdb; $table = WpExhibitConfig::table_name(WpExhibitConfig::$PARROTABLE_URLS_TABLE_KEY); $testurl = $wpdb->get_var($wpdb->prepare("SELECT url FROM {$table} where url = %s", $url)); $testurl = stripslashes($testurl); return $url == $testurl; }
static function insert_url() { $url = urldecode($_POST['url']); if ($url) { global $wpdb; $table = WpExhibitConfig::table_name(WpExhibitConfig::$PARROTABLE_URLS_TABLE_KEY); $wpdb->query($wpdb->prepare("INSERT INTO {$table} (url) VALUES (%s);", $url)); } }
static function setup_table($table_name, $creation_sql) { $table_name = WpExhibitConfig::table_name($table_name); $sql = "CREATE TABLE {$table_name} {$creation_sql}"; if (get_option(WpExhibitConfig::$WP_EXHIBIT_DB_VERSION_KEY) != WpExhibitConfig::$DB_VERSION) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); } }
function getTableName() { return WpExhibitConfig::table_name(WpExhibitConfig::$DATASCRAPS_TABLE_KEY); }
static function json_for($exhibit_id) { global $wpdb; $table = WpExhibitConfig::table_name(WpExhibitConfig::$GEOCODE_TABLE_KEY); $query = "SELECT lat, lng, addressField, datum_id FROM {$table} WHERE exhibit_id = %d"; $query = $wpdb->prepare($query, $exhibit_id); $data = $wpdb->get_results($query, ARRAY_A); $latlngs = array(); foreach ($data as $row) { $latlngs['items'][] = array('id' => $row['datum_id'], $row['addressField'] . '_generatedLatLng' => $row['lat'] . ',' . $row['lng']); } $latlng_json = json_encode($latlngs); return $latlng_json; }
function getTableName() { return WpExhibitConfig::table_name(WpExhibitConfig::$EXHIBITS_TABLE_KEY); }