当前位置: 首页>>代码示例>>PHP>>正文


PHP wpdb::get_var方法代码示例

本文整理汇总了PHP中wpdb::get_var方法的典型用法代码示例。如果您正苦于以下问题:PHP wpdb::get_var方法的具体用法?PHP wpdb::get_var怎么用?PHP wpdb::get_var使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wpdb的用法示例。


在下文中一共展示了wpdb::get_var方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: musicmate_get_store_products

function musicmate_get_store_products($product_cnt = 1)
{
    //Connect to the OSCommerce database
    $storedatabase = new wpdb(get_option('oscimp_dbuser'), get_option('oscimp_dbpwd'), get_option('oscimp_dbname'), get_option('oscimp_dbhost'));
    $prodVal = '';
    for ($i = 0; $i < $product_cnt; $i++) {
        //Get a random product
        $product_count = 0;
        while ($product_count == 0) {
            $product_id = rand(0, 30);
            $product_count = $storedatabase->get_var("SELECT COUNT(*) FROM products WHERE products_id={$product_id} AND products_status=1");
        }
        //Get product image, name and URL
        $product_image = $storedatabase->get_var("SELECT products_image FROM products WHERE products_id={$product_id}");
        $product_name = $storedatabase->get_var("SELECT products_name FROM products_description WHERE products_id={$product_id}");
        $store_url = get_option('oscimp_store_url');
        $image_folder = get_option('oscimp_prod_img_folder');
        //Build the HTML code
        $prodVal .= '<div class="store_product">';
        $prodVal .= '<a href="' . $store_url . 'product_info.php?products_id=' . $product_id . '"><img src="' . $image_folder . $product_image . '" /></a><br />';
        $prodVal .= '<a href="' . $store_url . 'product_info.php?products_id=' . $product_id . '">' . $product_name . '</a>';
        $prodVal .= '</div>';
    }
    return $prodVal;
}
开发者ID:Hal93,项目名称:Wordpress-Music-Theme---Plugin,代码行数:25,代码来源:musicmate.php

示例2:

 function global_site_search_page_setup()
 {
     $page_id = get_option('global_site_search_page', false);
     if (empty($page_id) || !is_object(get_post($page_id)) && is_super_admin()) {
         // a page hasn't been set - so check if there is already one with the base name
         $page_id = $this->db->get_var($this->db->prepare("SELECT ID FROM {$this->db->posts} WHERE post_name = %s AND post_type = 'page'", $this->global_site_search_base));
         if (empty($page_id)) {
             // Doesn't exist so create the page
             $page_id = wp_insert_post(array("post_content" => '', "post_title" => __('Site Search', 'globalsitesearch'), "post_excerpt" => '', "post_status" => 'publish', "comment_status" => 'closed', "ping_status" => 'closed', "post_name" => $this->global_site_search_base, "post_type" => 'page'));
             flush_rewrite_rules();
         }
         update_option('global_site_search_page', $page_id);
     }
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:14,代码来源:global-site-search.php

示例3: getTopFailedLogins

    /**
     * @param int $limit
     * @return mixed
     */
    public function getTopFailedLogins($limit = 10)
    {
        $interval = 'UNIX_TIMESTAMP(DATE_SUB(NOW(), interval 7 day))';
        switch (wfConfig::get('email_summary_interval', 'weekly')) {
            case 'daily':
                $interval = 'UNIX_TIMESTAMP(DATE_SUB(NOW(), interval 1 day))';
                break;
            case 'monthly':
                $interval = 'UNIX_TIMESTAMP(DATE_SUB(NOW(), interval 1 month))';
                break;
        }
        $failedLogins = $this->db->get_results($this->db->prepare(<<<SQL
SELECT wfl.*,
sum(wfl.fail) as fail_count
FROM {$this->db->base_prefix}wfLogins wfl
WHERE wfl.fail = 1
AND wfl.ctime > {$interval}
GROUP BY wfl.username
ORDER BY fail_count DESC
LIMIT %d
SQL
, $limit));
        foreach ($failedLogins as &$login) {
            $exists = $this->db->get_var($this->db->prepare(<<<SQL
SELECT !ISNULL(ID) FROM {$this->db->base_prefix}users WHERE user_login = '%s' OR user_email = '%s'
SQL
, $login->username, $login->username));
            $login->is_valid_user = $exists;
        }
        return $failedLogins;
    }
开发者ID:Jerram-Marketing,项目名称:Gummer-Co,代码行数:35,代码来源:wfActivityReport.php

示例4: select_translation_id

 private function select_translation_id($where, $prepare_args)
 {
     $this->translation_id = $this->wpdb->get_var("SELECT translation_id FROM {$this->wpdb->prefix}{$this->table}\n\t\t\t WHERE" . $this->wpdb->prepare($where, $prepare_args) . " LIMIT 1");
     if (!$this->translation_id) {
         throw new InvalidArgumentException('No translation entry found for query: ' . serialize($where) . serialize($prepare_args));
     }
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:7,代码来源:class-wpml-tm-icl-translations.php

示例5: array

 /**
  * Build login cookie.
  */
 function build_blog_cookie($action = 'login', $userblog_id = '')
 {
     global $blog_id;
     if ($action == '') {
         $action = 'login';
     }
     $url = false;
     if (class_exists('domain_map') && defined('DOMAIN_MAPPING')) {
         $domain = $this->db->get_var("SELECT domain FROM {$this->db->dmtable} WHERE blog_id = '{$userblog_id}' ORDER BY id LIMIT 1");
         if ($domain) {
             $dom = str_replace('.', '', $domain);
             $url = 'http://' . $domain . '/';
         }
     } else {
         $domains = $this->db->get_row("SELECT domain, path FROM {$this->db->blogs} WHERE blog_id = '{$userblog_id}' LIMIT 1");
         $dom = str_replace('.', '', $domains->domain);
         $url = 'http://' . $domains->domain . $domains->path;
     }
     if ($url) {
         $key = get_site_option("multi_domains_cross_domain_{$dom}", array());
         $user_id = get_current_user_id();
         if (!isset($key[$user_id]['action']) || isset($key[$user_id]['action']) && $key[$user_id]['action'] !== $action) {
             $key[$user_id] = array('domain' => $url, 'action' => $action);
             update_site_option("multi_domains_cross_domain_{$dom}", $key);
         }
         $hash = md5(AUTH_KEY . 'multi_domains');
         if ($blog_id !== $userblog_id && 'login' == $action) {
             // Removing transient check
             echo '<link rel="stylesheet" href="' . $url . $hash . '.css?build=' . date("Ymd", strtotime('-24 days')) . '&id=' . $user_id . '" type="text/css" media="screen" />';
             set_transient("multi_domains_{$dom}_{$user_id}", 'add', 60 * 15);
         }
     }
 }
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:36,代码来源:multi-domains.php

示例6: site_get_avatar

function site_get_avatar($avatar, $id_or_email, $size, $default, $alt)
{
    $email = '';
    if (is_numeric($id_or_email)) {
        $id = (int) $id_or_email;
        $user = get_userdata($id);
        if ($user) {
            $email = $user->user_email;
        }
    } elseif (is_object($id_or_email)) {
        $email = $id_or_email->comment_author_email;
    }
    $forum_db = '';
    $img_folder = '';
    // No trailing slash
    $img_path = $img_folder . '/image.php?u=';
    $my_wpdb = new wpdb(DB_USER, DB_PASSWORD, $forum_db, DB_HOST);
    $myrows = $my_wpdb->get_var($my_wpdb->prepare("SELECT userid\n    FROM " . $forum_db . ".vb_user\n    WHERE email = %s LIMIT 1", array($email)));
    if ($myrows != '') {
        $img = $img_path . $myrows;
    } elseif ($avatar) {
        return $avatar;
    } else {
        $img = $default;
    }
    $my_avatar = '<img src="' . $img . '" alt="' . $alt . '" height="' . $size . '" width="' . $size . '" class="avatar avatar-50 photo grav-hashed grav-hijack" />';
    return $my_avatar;
}
开发者ID:richard4339,项目名称:wp-vb-avatars,代码行数:28,代码来源:wp-vb-avatars.php

示例7: query

 /**
  * Execute the query, with the current variables.
  *
  * @since 3.1.0
  */
 public function query()
 {
     $qv =& $this->query_vars;
     $this->request = "SELECT {$this->query_fields} {$this->query_from} {$this->query_where} {$this->query_orderby} {$this->query_limit}";
     if (is_array($qv['fields']) || 'all' == $qv['fields']) {
         $this->results = $this->db->get_results($this->request);
     } else {
         $this->results = $this->db->get_col($this->request);
     }
     /**
      * Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance.
      *
      * @since 3.2.0
      *
      * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query.
      */
     if (isset($qv['count_total']) && $qv['count_total']) {
         $this->total_users = $this->db->get_var(apply_filters('found_users_query', 'SELECT FOUND_ROWS()'));
     }
     if (!$this->results) {
         return;
     }
     if ('all_with_meta' == $qv['fields']) {
         cache_users($this->results);
         $r = array();
         foreach ($this->results as $userid) {
             $r[$userid] = new WP_User($userid, '', $qv['blog_id']);
         }
         $this->results = $r;
     } elseif ('all' == $qv['fields']) {
         foreach ($this->results as $key => $user) {
             $this->results[$key] = new WP_User($user, '', $qv['blog_id']);
         }
     }
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:40,代码来源:class-wp-user-query.php

示例8: get_lang_data_by_iso

 /**
  * @param  string $iso Something like de_AT
  *
  * @param string $field the field which should be queried
  * @return mixed
  */
 public function get_lang_data_by_iso($iso, $field = 'native_name')
 {
     $iso = str_replace('_', '-', $iso);
     $query = $this->wpdb->prepare("SELECT `{$field}`\n\t\t\tFROM `{$this->table_name}`\n\t\t\tWHERE `http_name` = " . "%s LIMIT 1", $iso);
     $result = $this->wpdb->get_var($query);
     $return = NULL === $result ? '' : $result;
     return $return;
 }
开发者ID:ycms,项目名称:framework,代码行数:14,代码来源:Mlp_Language_Api.php

示例9: find

 /**
  * @param array $args
  * @param string $output_type
  * @return int|mixed
  */
 public function find($args, $output_type = OBJECT)
 {
     $args = wp_parse_args($args, array('select' => '*', 'offset' => 0, 'limit' => 1, 'orderby' => 'id', 'order' => 'DESC', 'email' => '', 'method' => '', 'datetime_after' => '', 'datetime_before' => '', 'include_errors' => true));
     $where = array();
     $params = array();
     // build general select from query
     $query = sprintf("SELECT %s FROM `%s`", $args['select'], $this->table_name);
     // add email to WHERE clause
     if ('' !== $args['email']) {
         $where[] = 'email LIKE %s';
         $params[] = '%%' . $this->db->esc_like($args['email']) . '%%';
     }
     // add method to WHERE clause
     if ('' !== $args['method']) {
         $where[] = 'method = %s';
         $params[] = $args['method'];
     }
     // add datetime to WHERE clause
     if ('' !== $args['datetime_after']) {
         $where[] = 'datetime >= %s';
         $params[] = $args['datetime_after'];
     }
     if ('' !== $args['datetime_before']) {
         $where[] = 'datetime <= %s';
         $params[] = $args['datetime_before'];
     }
     if (!$args['include_errors']) {
         $where[] = 'success = %d';
         $params[] = 1;
     }
     // add where parameters
     if (count($where) > 0) {
         $query .= ' WHERE ' . implode(' AND ', $where);
     }
     // prepare parameters
     if (!empty($params)) {
         $query = $this->db->prepare($query, $params);
     }
     // return result count
     if ($args['select'] === 'COUNT(*)') {
         return (int) $this->db->get_var($query);
     }
     // return single row
     if ($args['limit'] === 1) {
         $query .= ' LIMIT 1';
         return $this->db->get_row($query);
     }
     // perform rest of query
     $args['limit'] = absint($args['limit']);
     $args['offset'] = absint($args['offset']);
     $args['orderby'] = preg_replace("/[^a-zA-Z]/", "", $args['orderby']);
     $args['order'] = preg_replace("/[^a-zA-Z]/", "", $args['order']);
     // add ORDER BY, OFFSET and LIMIT to SQL
     $query .= sprintf(' ORDER BY `%s` %s LIMIT %d, %d', $args['orderby'], $args['order'], $args['offset'], $args['limit']);
     return $this->db->get_results($query, $output_type);
 }
开发者ID:NClaus,项目名称:Ambrose,代码行数:61,代码来源:class-logger.php

示例10: _record_transaction

 /**
  * Records transaction into database.
  *
  * @access protected
  * @param type $user_id
  * @param type $sub_id
  * @param type $amount
  * @param type $currency
  * @param type $timestamp
  * @param type $paypal_ID
  * @param type $status
  * @param type $note
  */
 protected function _record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $paypal_ID, $status, $note)
 {
     $data = array('transaction_subscription_ID' => $sub_id, 'transaction_user_ID' => $user_id, 'transaction_paypal_ID' => $paypal_ID, 'transaction_stamp' => $timestamp, 'transaction_currency' => $currency, 'transaction_status' => $status, 'transaction_total_amount' => (int) round($amount * 100), 'transaction_note' => $note, 'transaction_gateway' => $this->gateway);
     $existing_id = $this->db->get_var($this->db->prepare("SELECT transaction_ID FROM " . MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION . " WHERE transaction_paypal_ID = %s LIMIT 1", $paypal_ID));
     if (!empty($existing_id)) {
         $this->db->update(MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION, $data, array('transaction_ID' => $existing_id));
     } else {
         $this->db->insert(MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION, $data);
     }
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:23,代码来源:Gateway.php

示例11:

 function get_meta($key, $default = false)
 {
     $sql = $this->db->prepare('SELECT meta_value FROM ' . MEMBERSHIP_TABLE_SUBSCRIPTION_META . ' WHERE meta_key = %s AND sub_id = %d', $key, $this->id);
     $row = $this->db->get_var($sql);
     if (empty($row)) {
         return $default;
     } else {
         return $row;
     }
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:10,代码来源:Subscription.php

示例12: fillParentId

 private function fillParentId($metaEntityName, $where, $id)
 {
     $entityInfo = $this->dbSchemaInfo->getEntityInfo($metaEntityName);
     $parentReference = $entityInfo->parentReference;
     $parent = $entityInfo->references[$parentReference];
     $vpIdTable = $this->dbSchemaInfo->getPrefixedTableName('vp_id');
     $entityTable = $this->dbSchemaInfo->getPrefixedTableName($metaEntityName);
     $parentTable = $this->dbSchemaInfo->getTableName($parent);
     $idColumnName = $this->dbSchemaInfo->getEntityInfo($metaEntityName)->idColumnName;
     $where["vp_{$parentReference}"] = $this->database->get_var("SELECT HEX(vp_id) FROM {$vpIdTable} WHERE `table` = '{$parentTable}' AND ID = (SELECT {$parentReference} FROM {$entityTable} WHERE {$idColumnName} = {$id})");
     return $where;
 }
开发者ID:wp-cpm,项目名称:versionpress,代码行数:12,代码来源:WpdbMirrorBridge.php

示例13: get_mapped_domain

 /**
  * Get the primary domain if domain mapping is active
  *
  * @return string
  */
 private function get_mapped_domain()
 {
     if (empty($this->wpdb->dmtable)) {
         return '';
     }
     $sql = 'SELECT domain FROM ' . $this->wpdb->dmtable . ' WHERE active = 1 AND blog_id = %s LIMIT 1';
     $sql = $this->wpdb->prepare($sql, get_current_blog_id());
     $domain = $this->wpdb->get_var($sql);
     if ('' === $domain) {
         return '';
     }
     return (is_ssl() ? 'https://' : 'http://') . $domain;
 }
开发者ID:ycms,项目名称:multilingual-press,代码行数:18,代码来源:Mlp_Duplicate_Blogs.php

示例14: dontSeeInDatabase

 /**
  * Checks whether or not a record doesn't exist in the database.
  *
  * @since 1.0.0
  *
  * @access public
  * @param string $table The table name.
  * @param array $criteria The array of conditions.
  */
 public function dontSeeInDatabase($table, $criteria = array())
 {
     $query = $this->_prepareQuery($table, 'count(*)', $criteria);
     $this->debugSection('Query', $query);
     $suppress_errors = $this->_wpdb->suppress_errors(true);
     $res = $this->_wpdb->get_var($query);
     $this->_wpdb->suppress_errors($suppress_errors);
     if (!empty($this->_wpdb->last_error)) {
         $this->fail('Database error: ' . $this->_wpdb->last_error);
         return;
     }
     $this->assertLessThan(1, $res, 'Matching records found');
 }
开发者ID:gedex,项目名称:wp-codeception,代码行数:22,代码来源:Wpdb.php

示例15: set_found_networks

 /**
  * Populates found_networks and max_num_pages properties for the current query
  * if the limit clause was used.
  *
  * @since 4.6.0
  * @access private
  */
 private function set_found_networks()
 {
     if ($this->query_vars['number'] && !$this->query_vars['no_found_rows']) {
         /**
          * Filters the query used to retrieve found network count.
          *
          * @since 4.6.0
          *
          * @param string           $found_networks_query SQL query. Default 'SELECT FOUND_ROWS()'.
          * @param WP_Network_Query $network_query        The `WP_Network_Query` instance.
          */
         $found_networks_query = apply_filters('found_networks_query', 'SELECT FOUND_ROWS()', $this);
         $this->found_networks = (int) $this->db->get_var($found_networks_query);
     }
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:22,代码来源:class-wp-network-query.php


注:本文中的wpdb::get_var方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。