zoukankan      html  css  js  c++  java
  • drupal sql 源码解析query.inc 文件

    query.inc 文件:

    sql语句:

     $this->condition($field);
    1707 line
    public function condition($field, $value = NULL, $operator = NULL) {
    if (!isset($operator)) {
    if (is_array($value)) {
    $operator = 'IN';
    }
    elseif (!isset($value)) {
    $operator = 'IS NULL';
    }
    else {
    $operator = '=';
    }
    }
    $this->conditions[] = array(
    'field' => $field,
    'value' => $value,
    'operator' => $operator,
    );

    $this->changed = TRUE;

    return $this;
    }

    这里会放到 $this->conditions[] 中

    $operator = $connection->mapConditionOperator($condition['operator']);

    mapConditionOperator 函数:

    protected function mapConditionOperator($operator) {
    // $specials does not use drupal_static as its value never changes.
    static $specials = array(
    'BETWEEN' => array('delimiter' => ' AND '),
    'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
    'NOT IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
    'EXISTS' => array('prefix' => ' (', 'postfix' => ')'),
    'NOT EXISTS' => array('prefix' => ' (', 'postfix' => ')'),
    'IS NULL' => array('use_value' => FALSE),
    'IS NOT NULL' => array('use_value' => FALSE),
    // Use backslash for escaping wildcard characters.
    'LIKE' => array('postfix' => " ESCAPE '\\'"),
    'NOT LIKE' => array('postfix' => " ESCAPE '\\'"),
    // These ones are here for performance reasons.
    '=' => array(),
    '<' => array(),
    '>' => array(),
    '>=' => array(),
    '<=' => array(),
    );
    if (isset($specials[$operator])) {
    $return = $specials[$operator];
    }
    else {
    // We need to upper case because PHP index matches are case sensitive but
    // do not need the more expensive drupal_strtoupper because SQL statements are ASCII.
    $operator = strtoupper($operator);
    $return = isset($specials[$operator]) ? $specials[$operator] : array();
    }

    $return += array('operator' => $operator);

    return $return;
    这些应该是condition支持的吧


  • 相关阅读:
    Xcode安装Cocos2d-iphone
    Java最重要的21个技术点和知识点之JAVA基础
    Java最重要的21个技术点和知识点之JAVA面向对象
    Java最重要的21个技术点和知识点之JAVA集合框架、异常类、IO
    Java最重要的21个技术点和知识点之JAVA多线程、时间处理、数据格式
    Java最重要的21个技术点和知识点
    Linux 条件变量
    getcwd
    struct stat结构体简介
    SSL 程序设计初步介绍
  • 原文地址:https://www.cnblogs.com/cbugs/p/7016515.html
Copyright © 2011-2022 走看看