GetTable() . ' WHERE occurrence_id IN (' . implode( ',', $occurrence_ids ) . ')'; // Execute query. parent::DeleteQuery( $sql ); } } public function LoadByNameAndOccurrenceId( $meta_name, $occurrence_id ) { return $this->Load( 'occurrence_id = %d AND name = %s', array( $occurrence_id, $meta_name ) ); } /** * Get distinct values of IPs. * * @param int $limit - (Optional) Limit. * @return array - Distinct values of IPs. */ public function GetMatchingIPs( $limit = null ) { $_wpdb = $this->connection; $sql = "SELECT DISTINCT value FROM {$this->GetTable()} WHERE name = \"ClientIP\""; if ( ! is_null( $limit ) ) { $sql .= ' LIMIT ' . $limit; } $ips = $_wpdb->get_col( $sql ); foreach ( $ips as $key => $ip ) { $ips[ $key ] = str_replace( '"', '', $ip ); } return array_unique( $ips ); } /** * Create relevant indexes on the metadata table. */ public function create_indexes() { $db_connection = $this->get_connection(); // check if an index exists. $index_exists = false; if ( $db_connection->query( 'SELECT COUNT(1) IndexIsThere FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema=DATABASE() AND table_name="' . $this->GetTable() . '" AND index_name="name_value"' ) ) { // query succeeded, does index exist? $index_exists = ( isset( $db_connection->last_result[0]->IndexIsThere ) ) ? $db_connection->last_result[0]->IndexIsThere : false; } // if no index exists then make one. if ( ! $index_exists ) { $db_connection->query( 'CREATE INDEX name_value ON ' . $this->GetTable() . ' (name, value(64))' ); } } }