search
Homephp教程php手册tp2.2支持子查询

使tp2.2支持子查询,比较上线的项目 没办法总升级框架....tp3.0以下不能用子查询 比较无语了 更改后使用方法和tp3.0一样
更改/ThinkPHP/Lib/Think/Db/Db.class.php和/ThinkPHP/Lib/Think/Core/Model.class.php

懒人给了压缩包 tp2.1和2.2通用
直接解压到/ThinkPHP/Lib/Think/Core 目录下


Model.class.php select函数改为public function select($options=array()) {<br>         if(is_string($options) || is_numeric($options)) {<br>             // 根据主键查询<br>             $pk   =  $this->getPk();<br>             if(strpos($options,',')) {<br>                 $where[$pk] =  array('IN',$options);<br>             }else{<br>                 $where[$pk]   =  $options;<br>             }<br>             $options =  array();<br>             $options['where'] =  $where;<br>         }elseif(false === $options){<br>             $options =  array();<br>             // 分析表达式<br>             $options =  $this->_parseOptions($options);<br>             return  '( '.$this->db->buildSelectSql($options).' )';<br>         }<br>         // 分析表达式<br>         $options =  $this->_parseOptions($options);<br>         $resultSet = $this->db->select($options);<br>         if(false === $resultSet) {<br>             return false;<br>         }<br>         if(empty($resultSet)) { // 查询结果为空<br>             return null;<br>         }<br>         $this->_after_select($resultSet,$options);<br>         return $resultSet;<br>     }Db.class.php parseTable函数改为protected function parseTable($tables) {<br>         if(is_array($tables)) {// 支持别名定义<br>             $array   =  array();<br>             foreach ($tables as $table=>$alias){<br>                 if(!is_numeric($table))<br>                     $array[] =  $this->parseKey($table).' '.$this->parseKey($alias);<br>                 else<br>                     $array[] =  $this->parseKey($table);<br>             }<br>             $tables  =  $array;<br>         }elseif(is_string($tables)){<br>             $tables  =  explode(',',$tables);<br>             //array_walk($tables, array(&$this, 'parseKey'));//支持子查询 取消过滤<br>         }<br>         return implode(',',$tables);<br>     }

附件 Core.zip ( 16.2 KB 下载:143 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment