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


PHP wpdb::get_results方法代码示例

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


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

示例1: setTable

 /**
  * Bind model to database table
  * @param string $tableName
  * @return PMXI_Model
  */
 public function setTable($tableName)
 {
     if (!is_null($this->table)) {
         throw new Exception('Table name cannot be changed once being set.');
     }
     $this->table = $tableName;
     if (!isset(self::$meta_cache[$this->table])) {
         $tableMeta = $this->wpdb->get_results("SHOW COLUMNS FROM {$this->table}", ARRAY_A);
         $primary = array();
         $auto_increment = false;
         foreach ($tableMeta as $colMeta) {
             if ('PRI' == $colMeta['Key']) {
                 $primary[] = $colMeta['Field'];
             }
             if ('auto_increment' == $colMeta['Extra']) {
                 $auto_increment = true;
                 break;
                 // no point to iterate futher since auto_increment means corresponding primary key is simple
             }
         }
         self::$meta_cache[$this->table] = array('primary' => $primary, 'auto_increment' => $auto_increment);
     }
     $this->primary = self::$meta_cache[$this->table]['primary'];
     $this->auto_increment = self::$meta_cache[$this->table]['auto_increment'];
     return $this;
 }
开发者ID:thabofletcher,项目名称:tc-site,代码行数:31,代码来源:model.php

示例2: fetchAll

 /**
  * {@inheritdoc}
  */
 public function fetchAll($sql)
 {
     $sql = $this->_prepareSql($sql);
     $result = $this->_db->get_results($sql, ARRAY_A);
     $this->_checkError();
     return $result;
 }
开发者ID:JBZoo,项目名称:CrossCMS,代码行数:10,代码来源:Database.php

示例3: load

 public function load($staff_id)
 {
     $data = $this->wpdb->get_results('
         SELECT c.name AS category_name, s.*
         FROM ' . AB_Category::getTableName() . ' c
         INNER JOIN ' . AB_Service::getTableName() . ' s ON c.id = s.category_id
     ', ARRAY_A);
     if (!$data) {
         $data = array();
     }
     $this->uncategorized_services = AB_Service::query('s')->where('s.category_id', null)->fetchArray();
     $staff_services = AB_StaffService::query('ss')->select('ss.service_id, ss.price, ss.capacity')->where('ss.staff_id', $staff_id)->fetchArray();
     if ($staff_services) {
         foreach ($staff_services as $staff_service) {
             $this->selected[$staff_service['service_id']] = array('price' => $staff_service['price'], 'capacity' => $staff_service['capacity']);
         }
     }
     foreach ($data as $row) {
         if (!isset($this->collection[$row['category_id']])) {
             $abCategory = new AB_Category();
             $abCategory->set('id', $row['category_id']);
             $abCategory->set('name', $row['category_name']);
             $this->collection[$row['category_id']] = $abCategory;
         }
         unset($row['category_name']);
         $abService = new AB_Service($row);
         $this->category_services[$row['category_id']][] = $abService->get('id');
         $this->collection[$row['category_id']]->addService($abService);
     }
 }
开发者ID:patrickcurl,项目名称:monks,代码行数:30,代码来源:AB_StaffServicesForm.php

示例4: getResults

 public function getResults($query, $parameters = array())
 {
     if (!empty($parameters)) {
         $query = str_replace('?', '%s', $query);
         $query = $this->wpdb->prepare($query, $parameters);
     }
     return $this->wpdb->get_results($query, ARRAY_A);
 }
开发者ID:nikibrown,项目名称:2014-Nerd-presentation,代码行数:8,代码来源:WpDatabase.php

示例5: fetchAll

 /**
  * Fetch all results for the supplied SQL statement.
  *
  * @param string|\Dewdrop\Db\Select $sql
  * @param array $bind
  * @param string $fetchMode
  * @return array
  */
 public function fetchAll($sql, $bind = array(), $fetchMode = null)
 {
     if (null === $fetchMode) {
         $fetchMode = ARRAY_A;
     }
     $sql = $this->adapter->prepare($sql, $bind);
     $rs = $this->execWpdb($this->wpdb->get_results($sql, $fetchMode));
     return $rs;
 }
开发者ID:bravadomizzou,项目名称:dewdrop,代码行数:17,代码来源:Wpdb.php

示例6: translations

 /**
  * @return WPML_TM_ICL_Translations[]
  */
 public function translations()
 {
     if ((bool) $this->related === false) {
         $translation_ids = $this->wpdb->get_results("SELECT translation_id, language_code\n\t\t\t FROM {$this->wpdb->prefix}{$this->table}\n\t\t\t WHERE trid = " . $this->trid());
         foreach ($translation_ids as $row) {
             $this->related[$row->language_code] = $this->tm_records->icl_translations_by_translation_id($row->translation_id);
         }
     }
     return $this->related;
 }
开发者ID:agiper,项目名称:wordpress,代码行数:13,代码来源:class-wpml-tm-icl-translations.php

示例7: retrieve

 /**
  * @param string $query
  * @param array $args
  * @param int $elements_num
  *
  * @return array
  */
 public function retrieve($query, $args, $elements_num)
 {
     $result = array();
     $offset = 0;
     while ($offset < $elements_num) {
         $new_query = $query . sprintf(' LIMIT %d OFFSET %s', $this->chunk_size, $offset);
         $new_query = $this->wpdb->prepare($new_query, $args);
         $rowset = $this->wpdb->get_results($new_query, ARRAY_A);
         if (is_array($rowset) && count($rowset)) {
             $result = array_merge($result, $rowset);
         }
         $offset += $this->chunk_size;
     }
     return $result;
 }
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:22,代码来源:class-wpml-st-db-chunk-retrieve.php

示例8: array

 function get_active_subscriptions()
 {
     $where = array();
     $orderby = array();
     $where[] = "sub_active = 1";
     $orderby[] = 'id ASC';
     $sql = 'SELECT * FROM ' . MEMBERSHIP_TABLE_SUBSCRIPTIONS;
     if (!empty($where)) {
         $sql .= " WHERE " . implode(' AND ', $where);
     }
     if (!empty($orderby)) {
         $sql .= " ORDER BY " . implode(', ', $orderby);
     }
     return $this->db->get_results($sql);
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:15,代码来源:class.communication.php

示例9: get_forms

 /**
  * Gets all the rows in a particular range. Used by the list table class for fetching forms on a particular page.
  *
  * @param int $curr_page Current page of the list table.
  * @param int $per_page Number of items to fetch.
  * @return array A numerically indexed array of associative arrays, using column names as keys.
  **/
 public function get_forms($curr_page, $per_page, $post_type = false)
 {
     $start = ($curr_page - 1) * $per_page;
     $where = $post_type ? "post_type = '{$post_type}'" : 1;
     $query = "SELECT * FROM {$this->table_name} WHERE {$where} ORDER BY id DESC LIMIT {$start}, {$per_page}";
     return $this->db->get_results($query, ARRAY_A);
 }
开发者ID:poweronio,项目名称:mbsite,代码行数:14,代码来源:class-wpfepp-db-table.php

示例10: fleet_roster_handler

function fleet_roster_handler($atts)
{
    extract(shortcode_atts(array('prefix' => ''), $atts));
    $response = '';
    if ($prefix) {
        $novadb = new wpdb('<username>', '<user password>', '<database>', '<server>');
        if ($novadb->show_errors()) {
            return $novadb->show_errors();
        }
        $response = '';
        $query = "SELECT pos_name, pos_open from " . $prefix . "_positions_sto where pos_open > 0 order by pos_dept, pos_order;";
        $rows = $novadb->get_results($query);
        if (!$novadb->num_rows) {
            return "No Positions available at this time.";
        }
        $i = 0;
        foreach ($rows as $row) {
            $response .= $row->pos_name;
            if ($row->pos_open > 1) {
                $response .= ' (' . $row->pos_open . ' open)';
            }
            $i++;
            if ($i < $novadb->num_rows) {
                $response .= ' - ';
            }
        }
        return $response;
    }
    return 'Please enter a Command Prefix Code.';
}
开发者ID:arcee123,项目名称:WP_Plugin_NOVA,代码行数:30,代码来源:NOVA_Openings.php

示例11: download

 /**
  * Log download
  *
  * If you are viewing the right admin page and you use the right GET
  * parameters, this will send the CSV version of the log.
  *
  * @return void
  */
 public function download()
 {
     if (!$this->isDownload()) {
         return;
     }
     // Generate a file name and query based on the group parameters
     $name = $this->downloadName();
     $where = $this->downloadWhere();
     // Add CSV headers
     header('Content-Type: text/csv');
     header('Content-Disposition: attachment; filename="' . $name . '.csv"');
     // Extract the log data from the database and convert it to CSV format
     $results = $this->database->get_results("\n            SELECT *\n            FROM {$this->table}\n            WHERE {$where}\n        ");
     // Print CSV output
     $csv = fopen('php://output', 'w');
     // Extract headings from a database row and add them to the CSV
     fputcsv($csv, $this->headings(end($results)));
     // Extract values from each result and add them to the CSV
     foreach ($results as $result) {
         fputcsv($csv, $this->values($result));
     }
     // Finish writing CSV
     fclose($csv);
     // Prevent the rest of the page appearing in the CSV file
     exit;
 }
开发者ID:castlegateit,项目名称:cgit-wp-postman,代码行数:34,代码来源:Lumberjack.php

示例12: 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

示例13: get_existing_translation_ids

 /**
  * @param $source_site_id
  * @param $target_site_id
  * @param $source_content_id
  * @param $target_content_id
  * @param $type
  * @return mixed
  */
 private function get_existing_translation_ids($source_site_id, $target_site_id, $source_content_id, $target_content_id, $type)
 {
     $sql = "\n\t\t\tSELECT DISTINCT `ml_source_blogid`, `ml_source_elementid`\n\t\t\tFROM {$this->link_table}\n\t\t\tWHERE (\n\t\t\t\t   ( `ml_blogid` = %d AND `ml_elementid` = %d )\n\t\t\t\tOR ( `ml_blogid` = %d AND `ml_elementid` = %d )\n\t\t\t\t)\n\t\t\t\tAND `ml_type` = %s";
     $query = $this->wpdb->prepare($sql, $source_site_id, $source_content_id, $target_site_id, $target_content_id, $type);
     $result = $this->wpdb->get_results($query, ARRAY_A);
     return $result;
 }
开发者ID:ycms,项目名称:framework,代码行数:15,代码来源:Mlp_Content_Relations.php

示例14: 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 'biweekly':
                $interval = 'UNIX_TIMESTAMP(DATE_SUB(NOW(), interval 14 day))';
                break;
            case 'monthly':
                $interval = 'UNIX_TIMESTAMP(DATE_SUB(NOW(), interval 1 month))';
                break;
        }
        $results = $this->db->get_results($this->db->prepare(<<<SQL
SELECT *,
sum(fail) as fail_count,
max(userID) as is_valid_user
FROM {$this->db->base_prefix}wfLogins
WHERE fail = 1
AND ctime > {$interval}
GROUP BY username
ORDER BY fail_count DESC
LIMIT %d
SQL
, $limit));
        return $results;
    }
开发者ID:rinodung,项目名称:myfreetheme,代码行数:29,代码来源:wfActivityReport.php

示例15: tgp_get_products

function tgp_get_products()
{
    // Connect to the database
    $db = new wpdb(get_option('db_user'), get_option('db_pass'), get_option('db_name'), get_option('db_host'));
    // Get values
    $store_url = get_option('store_url');
    $img_folder = get_option('img_folder');
    $num_products = get_option('num_products');
    // Get Products
    $products = $db->get_results("SELECT * FROM products LIMIT " . $num_products);
    // Build Output
    $output = '';
    if ($products) {
        foreach ($products as $product) {
            $output .= '<div class="tgp_product">';
            $output .= '<h3>' . $product->title . '</h3>';
            $output .= '<img src="' . $store_url . '/' . $img_folder . '/' . $product->image . '" alt="' . $product->title . '">';
            $output .= '<div class="price">' . $product->price . '</div>';
            $output .= '<div class="desc">' . wp_trim_words($product->description, 10) . '</div>';
            $output .= '<a href="' . $store_url . 'products/details/' . $product->id . '">Buy Now</a>';
        }
    } else {
        $output .= 'No products to list';
    }
    return $output;
}
开发者ID:alt3red,项目名称:thegamingplace,代码行数:26,代码来源:thegamingplace.php


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