本文介绍了php Codeigniter-执行库Subquery.php时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用子查询工作的库-Subquery.php
参考:

I have been using a library for subqueries to work - Subquery.phpRef : https://github.com/NTICompass/CodeIgniter-Subqueries

$this->db->select('test');
$this->db->select('test2');
$this->db->from('table');
$sub = $this->subquery->start_subquery('where_in');
$sub->select('IDs');
$sub->from('idTable');
$sub->where('date', '2011-07-10');
$this->subquery->end_subquery('id');

我认为以下语句:

$sub = $this->subquery->start_subquery('where_in');

包含错误。当我执行此行时,我得到一个空白页。
fn。 start_subquery是:

contains the error. When I execute this line, I get a blank page.The fn. start_subquery is:

function start_subquery($statement, $join_type = '', $join_on = 1){
        $db = $this->CI->load->database('', true); // after executing this statement, a blank page shows...
        $this->dbStack[] = $db;
        $this->statement[] = $statement;
        if(strtolower($statement) == 'join'){
            $this->join_type[] = $join_type;
            $this->join_on[] = $join_on;
        }
        return $db;
    }

仅供参考-在我的database.php中:

FYI - In my database.php:

$active_group = 'default'
$active_record = TRUE;

CI版本为2.1.0

And CI version is 2.1.0

推荐答案

嗯,明白了。正如我在第27行看到的子查询的源代码一样,它想调用 _compile_select get_compiled_select 。如果您可以签入CI的 DB_active_rec.php ,则 _compile_select 受保护,因此您无法从子查询中访问( 't的 db 的子类。

Hm, understand. As I see the subquery's source code in line 27, it wants to call _compile_select or get_compiled_select. If you can check in CI's DB_active_rec.php the _compile_select is protected so you can't access from Subquery (it isn't subclass of db).

可能的解决方案: _compile_select()应该是公共的,还是类 Subquery 应该是CI的db类的扩展。我认为您应该将此报告给Subquery的作者。

Possible solution: _compile_select() should public or class Subquery should be extend of CI's db class. I think you should report this to author of Subquery.

或者您可以扩展CI的db类:)

Or you can extend the CI's db class :)

对不起,我想写它作为评论。

Sorry - I want to write it as a comment.

这篇关于php Codeigniter-执行库Subquery.php时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 07:41