get_var example


        $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $user_ids );

        if ( $user_ids && ! $users_have_content ) {
            if ( $wpdb->get_var(
                "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $user_ids ) . ' ) LIMIT 1'
            ) ) {
                $users_have_content = true;
            } elseif ( $wpdb->get_var(
                "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $user_ids ) . ' ) LIMIT 1'
            ) ) {
                $users_have_content = true;
            }
if ( $this->check_current_query && $this->check_safe_collation( $query ) ) {
                $this->check_current_query = false;
            }

            $this->query( $query );
        }

        $new_array = array();
        // Extract the column values.         if ( $this->last_result ) {
            for ( $i = 0, $j = count( $this->last_result )$i < $j$i++ ) {
                $new_array[ $i ] = $this->get_var( null, $x$i );
            }
        }
        return $new_array;
    }

    /** * Retrieves an entire SQL result set from the database (i.e., many rows). * * Executes a SQL query and returns the entire SQL result. * * @since 0.71 * * @param string $query SQL query. * @param string $output Optional. Any of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants. * With one of the first three, return an array of rows indexed * from 0 by SQL result row number. Each row is an associative array * (column => value, ...), a numerically indexed array (0 => value, ...), * or an object ( ->column = value ), respectively. With OBJECT_K, * return an associative array of row objects keyed by the value * of each row's first column's value. Duplicate keys are discarded. * Default OBJECT. * @return array|object|null Database query results. */

function get_blog_status( $id$pref ) {
    global $wpdb;

    $details = get_site( $id );
    if ( $details ) {
        return $details->$pref;
    }

    return $wpdb->get_var( $wpdb->prepare( "SELECT %s FROM {$wpdb->blogs} WHERE blog_id = %d", $pref$id ) );
}

/** * Gets a list of most recently updated blogs. * * @since MU (3.0.0) * * @global wpdb $wpdb WordPress database abstraction object. * * @param mixed $deprecated Not used. * @param int $start Optional. Number of blogs to offset the query. Used to build LIMIT clause. * Can be used for pagination. Default 0. * @param int $quantity Optional. The maximum number of blogs to retrieve. Default 40. * @return array The list of blogs. */
_prime_term_caches( $term_ids$args['update_term_meta_cache'] );

                $term_objects = $this->populate_terms( $cache );
                $cache        = $this->format_terms( $term_objects$_fields );
            }

            $this->terms = $cache;
            return $this->terms;
        }

        if ( 'count' === $_fields ) {
            $count = $wpdb->get_var( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared             wp_cache_set( $cache_key$count, 'term-queries' );
            return $count;
        }

        $terms = $wpdb->get_results( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
        if ( empty( $terms ) ) {
            wp_cache_add( $cache_key, array(), 'term-queries' );
            return array();
        }

        


    $counts = wp_cache_get( $cache_key, 'counts' );
    if ( false == $counts ) {
        $and   = wp_post_mime_type_where( $mime_type );
        $count = $wpdb->get_results( "SELECT post_mime_type, COUNT( * ) AS num_posts FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' $and GROUP BY post_mime_type", ARRAY_A );

        $counts = array();
        foreach ( (array) $count as $row ) {
            $counts[ $row['post_mime_type'] ] = $row['num_posts'];
        }
        $counts['trash'] = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'trash' $and);

        wp_cache_set( $cache_key(object) $counts, 'counts' );
    }

    /** * Filters the attachment counts by mime type. * * @since 3.7.0 * * @param stdClass $counts An object containing the attachment counts by * mime type. * @param string|string[] $mime_type Array or comma-separated list of MIME patterns. */

    $check = apply_filters( "add_{$meta_type}_metadata", null, $object_id$meta_key$meta_value$unique );
    if ( null !== $check ) {
        return $check;
    }

    if ( $unique && $wpdb->get_var(
        $wpdb->prepare(
            "SELECT COUNT(*) FROM $table WHERE meta_key = %s AND $column = %d",
            $meta_key,
            $object_id
        )
    ) ) {
        return false;
    }

    $_meta_value = $meta_value;
    $meta_value  = maybe_serialize( $meta_value );

    

    $show_audio_playlist = apply_filters( 'media_library_show_audio_playlist', true );
    if ( null === $show_audio_playlist ) {
        $show_audio_playlist = $wpdb->get_var(
            "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'audio%' LIMIT 1"
        );
    }

    /** * Allows showing or hiding the "Create Video Playlist" button in the media library. * * By default, the "Create Video Playlist" button will always be shown in * the media library. If this filter returns `null`, a query will be run * to determine whether the media library contains any video items. This * was the default behavior prior to version 4.8.0, but this query is * expensive for large media libraries. * * @since 4.7.4 * @since 4.8.0 The filter's default value is `true` rather than `null`. * * @link https://core.trac.wordpress.org/ticket/31071 * * @param bool|null $show Whether to show the button, or `null` to decide based * on whether any video files exist in the media library. */
    return block_core_calendar_update_has_published_posts();
}

/** * Queries the database for any published post and saves * a flag whether any published post exists or not. * * @return bool Has any published posts or not. */
function block_core_calendar_update_has_published_posts() {
    global $wpdb;
    $has_published_posts = (bool) $wpdb->get_var( "SELECT 1 as test FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
    update_option( 'wp_calendar_block_has_published_posts', $has_published_posts );
    return $has_published_posts;
}

// We only want to register these functions and actions when // we are on single sites. On multi sites we use `post_count` option. if ( ! is_multisite() ) {
    /** * Handler for updating the has published posts flag when a post is deleted. * * @param int $post_id Deleted post ID. */

    private function prepare_sql_data() {
        global $wpdb;

        $mysql_server_type = $wpdb->db_server_info();

        $this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' );

        if ( stristr( $mysql_server_type, 'mariadb' ) ) {
            $this->is_mariadb                = true;
            $this->mysql_recommended_version = $this->mariadb_recommended_version;
        }

        $this->is_acceptable_mysql_version  = version_compare( $this->mysql_required_version, $this->mysql_server_version, '<=' );
        $this->is_recommended_mysql_version = version_compare( $this->mysql_recommended_version, $this->mysql_server_version, '<=' );
    }

    /** * Tests whether `wp_version_check` is blocked. * * It's possible to block updates with the `wp_version_check` filter, but this can't be checked * during an Ajax call, as the filter is never introduced then. * * This filter overrides a standard page request if it's made by an admin through the Ajax call * with the right query argument to check for this. * * @since 5.2.0 */

function display_setup_form( $error = null ) {
    global $wpdb;

    $user_table = ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) ) ) !== null );

    // Ensure that sites appear in search engines by default.     $blog_public = 1;
    if ( isset( $_POST['weblog_title'] ) ) {
        $blog_public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : $blog_public;
    }

    $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
    $user_name    = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
    $admin_email  = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : '';

    
<?php printf( __( 'In 2012, Akismet began using subscription plans for all accounts (even free ones). A plan has not been assigned to your account, and we&#8217;d appreciate it if you&#8217;d <a href="%s" target="_blank">sign into your account</a> and choose one.', 'akismet'), 'https://akismet.com/account/upgrade/' ); ?> <br /><br /> <?php printf( __( 'Please <a href="%s" target="_blank">contact our support team</a> with any questions.', 'akismet' ), 'https://akismet.com/contact/' ); ?> </p> </div> <?php elseif ( $type == 'new-key-valid' ) :
    global $wpdb;
    
    $check_pending_link = false;
    
    $at_least_one_comment_in_moderation = !! $wpdb->get_var( "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT 1" );
    
    if ( $at_least_one_comment_in_moderation)  {
        $check_pending_link = 'edit-comments.php?akismet_recheck=' . wp_create_nonce( 'akismet_recheck' );
    }
    ?> <div class="akismet-alert akismet-active"> <h3 class="akismet-key-status"><?php esc_html_e( 'Akismet is now protecting your site from spam. Happy blogging!', 'akismet' ); ?></h3> <?php if ( $check_pending_link ) { ?> <p class="akismet-description"><?php printf( __( 'Would you like to <a href="%s">check pending comments</a>?', 'akismet' )esc_url( $check_pending_link ) ); ?></p> <?php } ?> </div>

    $post_links = apply_filters( 'enclosure_links', $post_links$post->ID );

    foreach ( (array) $post_links as $url ) {
        $url = strip_fragment_from_url( $url );

        if ( '' !== $url && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) {

            $headers = wp_get_http_headers( $url );
            if ( $headers ) {
                $len           = isset( $headers['Content-Length'] ) ? (int) $headers['Content-Length'] : 0;
                $type          = isset( $headers['Content-Type'] ) ? $headers['Content-Type'] : '';
                $allowed_types = array( 'video', 'audio' );

                // Check to see if we can figure out the mime type from the extension.                 $url_parts = parse_url( $url );
                if ( false !== $url_parts && ! empty( $url_parts['path'] ) ) {
                    $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
                    

function network_domain_check() {
    global $wpdb;

    $sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) );
    if ( $wpdb->get_var( $sql ) ) {
        return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
    }
    return false;
}

/** * Allow subdomain installation * * @since 3.0.0 * @return bool Whether subdomain installation is allowed */
if ( get_query_var( 'day' ) ) {
        $query .= $wpdb->prepare( ' AND DAYOFMONTH(post_date) = %d', get_query_var( 'day' ) );
    }

    $key          = md5( $query );
    $last_changed = wp_cache_get_last_changed( 'posts' );
    $cache_key    = "find_post_by_old_slug:$key:$last_changed";
    $cache        = wp_cache_get( $cache_key, 'post-queries' );
    if ( false !== $cache ) {
        $id = $cache;
    } else {
        $id = (int) $wpdb->get_var( $query );
        wp_cache_set( $cache_key$id, 'post-queries' );
    }

    return $id;
}

/** * Find the post ID for redirecting an old date. * * @since 4.9.3 * @access private * * @see wp_old_slug_redirect() * @global wpdb $wpdb WordPress database abstraction object. * * @param string $post_type The current post type based on the query vars. * @return int The Post ID. */
if ( ! empty( $type ) ) {
        $query .= ' AND post_type = %s';
        $args[] = $post_type;
    }

    if ( ! empty( $status ) ) {
        $query .= ' AND post_status = %s';
        $args[] = $post_status;
    }

    if ( ! empty( $args ) ) {
        return (int) $wpdb->get_var( $wpdb->prepare( $query$args ) );
    }

    return 0;
}

/** * Creates a new post from the "Write Post" form using `$_POST` information. * * @since 2.1.0 * * @global WP_User $current_user * * @return int|WP_Error Post ID on success, WP_Error on failure. */
Home | Imprint | This part of the site doesn't use cookies.