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


PHP wpdb::_escape方法代码示例

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


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

示例1: get_network_ids

 /**
  * Used internally to get a list of network IDs matching the query vars.
  *
  * @since 4.6.0
  * @access protected
  *
  * @return int|array A single count of network IDs if a count query. An array of network IDs if a full query.
  */
 protected function get_network_ids()
 {
     $order = $this->parse_order($this->query_vars['order']);
     // Disable ORDER BY with 'none', an empty array, or boolean false.
     if (in_array($this->query_vars['orderby'], array('none', array(), false), true)) {
         $orderby = '';
     } elseif (!empty($this->query_vars['orderby'])) {
         $ordersby = is_array($this->query_vars['orderby']) ? $this->query_vars['orderby'] : preg_split('/[,\\s]/', $this->query_vars['orderby']);
         $orderby_array = array();
         foreach ($ordersby as $_key => $_value) {
             if (!$_value) {
                 continue;
             }
             if (is_int($_key)) {
                 $_orderby = $_value;
                 $_order = $order;
             } else {
                 $_orderby = $_key;
                 $_order = $_value;
             }
             $parsed = $this->parse_orderby($_orderby);
             if (!$parsed) {
                 continue;
             }
             if ('network__in' === $_orderby) {
                 $orderby_array[] = $parsed;
                 continue;
             }
             $orderby_array[] = $parsed . ' ' . $this->parse_order($_order);
         }
         $orderby = implode(', ', $orderby_array);
     } else {
         $orderby = "{$this->db->site}.id {$order}";
     }
     $number = absint($this->query_vars['number']);
     $offset = absint($this->query_vars['offset']);
     if (!empty($number)) {
         if ($offset) {
             $limits = 'LIMIT ' . $offset . ',' . $number;
         } else {
             $limits = 'LIMIT ' . $number;
         }
     }
     if ($this->query_vars['count']) {
         $fields = 'COUNT(*)';
     } else {
         $fields = "{$this->db->site}.id";
     }
     // Parse network IDs for an IN clause.
     if (!empty($this->query_vars['network__in'])) {
         $this->sql_clauses['where']['network__in'] = "{$this->db->site}.id IN ( " . implode(',', wp_parse_id_list($this->query_vars['network__in'])) . ' )';
     }
     // Parse network IDs for a NOT IN clause.
     if (!empty($this->query_vars['network__not_in'])) {
         $this->sql_clauses['where']['network__not_in'] = "{$this->db->site}.id NOT IN ( " . implode(',', wp_parse_id_list($this->query_vars['network__not_in'])) . ' )';
     }
     if (!empty($this->query_vars['domain'])) {
         $this->sql_clauses['where']['domain'] = $this->db->prepare("{$this->db->site}.domain = %s", $this->query_vars['domain']);
     }
     // Parse network domain for an IN clause.
     if (is_array($this->query_vars['domain__in'])) {
         $this->sql_clauses['where']['domain__in'] = "{$this->db->site}.domain IN ( '" . implode("', '", $this->db->_escape($this->query_vars['domain__in'])) . "' )";
     }
     // Parse network domain for a NOT IN clause.
     if (is_array($this->query_vars['domain__not_in'])) {
         $this->sql_clauses['where']['domain__not_in'] = "{$this->db->site}.domain NOT IN ( '" . implode("', '", $this->db->_escape($this->query_vars['domain__not_in'])) . "' )";
     }
     if (!empty($this->query_vars['path'])) {
         $this->sql_clauses['where']['path'] = $this->db->prepare("{$this->db->site}.path = %s", $this->query_vars['path']);
     }
     // Parse network path for an IN clause.
     if (is_array($this->query_vars['path__in'])) {
         $this->sql_clauses['where']['path__in'] = "{$this->db->site}.path IN ( '" . implode("', '", $this->db->_escape($this->query_vars['path__in'])) . "' )";
     }
     // Parse network path for a NOT IN clause.
     if (is_array($this->query_vars['path__not_in'])) {
         $this->sql_clauses['where']['path__not_in'] = "{$this->db->site}.path NOT IN ( '" . implode("', '", $this->db->_escape($this->query_vars['path__not_in'])) . "' )";
     }
     // Falsey search strings are ignored.
     if (strlen($this->query_vars['search'])) {
         $this->sql_clauses['where']['search'] = $this->get_search_sql($this->query_vars['search'], array("{$this->db->site}.domain", "{$this->db->site}.path"));
     }
     $join = '';
     $where = implode(' AND ', $this->sql_clauses['where']);
     $pieces = array('fields', 'join', 'where', 'orderby', 'limits', 'groupby');
     /**
      * Filters the network query clauses.
      *
      * @since 4.6.0
      *
      * @param array            $pieces A compacted array of network query clauses.
      * @param WP_Network_Query &$this  Current instance of WP_Network_Query, passed by reference.
//.........这里部分代码省略.........
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:101,代码来源:class-wp-network-query.php

示例2: escape

 /**
  * {@inheritdoc}
  */
 public function escape($text)
 {
     return $this->_db->_escape($text);
 }
开发者ID:JBZoo,项目名称:CrossCMS,代码行数:7,代码来源:Database.php

示例3: get_site_ids

 /**
  * Used internally to get a list of site IDs matching the query vars.
  *
  * @since 4.6.0
  * @access protected
  *
  * @return int|array A single count of site IDs if a count query. An array of site IDs if a full query.
  */
 protected function get_site_ids()
 {
     $order = $this->parse_order($this->query_vars['order']);
     // Disable ORDER BY with 'none', an empty array, or boolean false.
     if (in_array($this->query_vars['orderby'], array('none', array(), false), true)) {
         $orderby = '';
     } elseif (!empty($this->query_vars['orderby'])) {
         $ordersby = is_array($this->query_vars['orderby']) ? $this->query_vars['orderby'] : preg_split('/[,\\s]/', $this->query_vars['orderby']);
         $orderby_array = array();
         foreach ($ordersby as $_key => $_value) {
             if (!$_value) {
                 continue;
             }
             if (is_int($_key)) {
                 $_orderby = $_value;
                 $_order = $order;
             } else {
                 $_orderby = $_key;
                 $_order = $_value;
             }
             $parsed = $this->parse_orderby($_orderby);
             if (!$parsed) {
                 continue;
             }
             if ('site__in' === $_orderby || 'network__in' === $_orderby) {
                 $orderby_array[] = $parsed;
                 continue;
             }
             $orderby_array[] = $parsed . ' ' . $this->parse_order($_order);
         }
         $orderby = implode(', ', $orderby_array);
     } else {
         $orderby = "blog_id {$order}";
     }
     $number = absint($this->query_vars['number']);
     $offset = absint($this->query_vars['offset']);
     if (!empty($number)) {
         if ($offset) {
             $limits = 'LIMIT ' . $offset . ',' . $number;
         } else {
             $limits = 'LIMIT ' . $number;
         }
     }
     if ($this->query_vars['count']) {
         $fields = 'COUNT(*)';
     } else {
         $fields = 'blog_id';
     }
     // Parse site IDs for an IN clause.
     $site_id = absint($this->query_vars['ID']);
     if (!empty($site_id)) {
         $this->sql_clauses['where']['ID'] = $this->db->prepare('blog_id = %d', $site_id);
     }
     // Parse site IDs for an IN clause.
     if (!empty($this->query_vars['site__in'])) {
         $this->sql_clauses['where']['site__in'] = "blog_id IN ( " . implode(',', wp_parse_id_list($this->query_vars['site__in'])) . ' )';
     }
     // Parse site IDs for a NOT IN clause.
     if (!empty($this->query_vars['site__not_in'])) {
         $this->sql_clauses['where']['site__not_in'] = "blog_id NOT IN ( " . implode(',', wp_parse_id_list($this->query_vars['site__not_in'])) . ' )';
     }
     $network_id = absint($this->query_vars['network_id']);
     if (!empty($network_id)) {
         $this->sql_clauses['where']['network_id'] = $this->db->prepare('site_id = %d', $network_id);
     }
     // Parse site network IDs for an IN clause.
     if (!empty($this->query_vars['network__in'])) {
         $this->sql_clauses['where']['network__in'] = 'site_id IN ( ' . implode(',', wp_parse_id_list($this->query_vars['network__in'])) . ' )';
     }
     // Parse site network IDs for a NOT IN clause.
     if (!empty($this->query_vars['network__not_in'])) {
         $this->sql_clauses['where']['network__not_in'] = 'site_id NOT IN ( ' . implode(',', wp_parse_id_list($this->query_vars['network__not_in'])) . ' )';
     }
     if (!empty($this->query_vars['domain'])) {
         $this->sql_clauses['where']['domain'] = $this->db->prepare('domain = %s', $this->query_vars['domain']);
     }
     // Parse site domain for an IN clause.
     if (is_array($this->query_vars['domain__in'])) {
         $this->sql_clauses['where']['domain__in'] = "domain IN ( '" . implode("', '", $this->db->_escape($this->query_vars['domain__in'])) . "' )";
     }
     // Parse site domain for a NOT IN clause.
     if (is_array($this->query_vars['domain__not_in'])) {
         $this->sql_clauses['where']['domain__not_in'] = "domain NOT IN ( '" . implode("', '", $this->db->_escape($this->query_vars['domain__not_in'])) . "' )";
     }
     if (!empty($this->query_vars['path'])) {
         $this->sql_clauses['where']['path'] = $this->db->prepare('path = %s', $this->query_vars['path']);
     }
     // Parse site path for an IN clause.
     if (is_array($this->query_vars['path__in'])) {
         $this->sql_clauses['where']['path__in'] = "path IN ( '" . implode("', '", $this->db->_escape($this->query_vars['path__in'])) . "' )";
     }
     // Parse site path for a NOT IN clause.
//.........这里部分代码省略.........
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:101,代码来源:class-wp-site-query.php

示例4: escape

 /**
  * {@inheritdoc}
  * @codeCoverageIgnore
  */
 public function escape($text, $extra = false)
 {
     return $this->_db->_escape($text);
 }
开发者ID:jbzoo,项目名称:sqlbuilder,代码行数:8,代码来源:Wordpress.php


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