【问题标题】:Is there a function like _compile_select or get_compiled_select()?有没有像 _compile_select 或 get_compiled_select() 这样的函数?
【发布时间】:2012-03-03 04:33:39
【问题描述】:

看起来_compile_select 已被弃用,get_compiled_select 未添加到 2.1.0。有没有像这两个一样的其他功能?而且我很好奇。有什么特别的理由不将get_compiled_select() 添加到Active Record 并删除_compile_select

【问题讨论】:

    标签: codeigniter activerecord codeigniter-2


    【解决方案1】:

    我已将 get_compiled_select() 添加到 DB_active_rec.php,它似乎可以正常工作,但我不会删除 _compile_select(),因为它用于许多其他方法。

    添加此方法的拉取请求在这里,还有一些其他有用的方法,例如:

    • get_compiled_select()
    • get_compiled_insert()
    • get_compiled_update()
    • get_compiled_delete()

    https://github.com/EllisLab/CodeIgniter/pull/307

    如果你只想要方法,就是这样:

    /**
     * Get SELECT query string
     *
     * Compiles a SELECT query string and returns the sql.
     *
     * @access  public
     * @param   string  the table name to select from (optional)
     * @param   boolean TRUE: resets AR values; FALSE: leave AR vaules alone
     * @return  string
     */
    public function get_compiled_select($table = '', $reset = TRUE)
    {
        if ($table != '')
        {
            $this->_track_aliases($table);
            $this->from($table);
        }
    
        $select =  $this->_compile_select();
    
        if ($reset === TRUE)
        {
            $this->_reset_select();
        }
    
        return $select;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-02
      • 1970-01-01
      • 1970-01-01
      • 2016-09-19
      • 1970-01-01
      • 2020-01-02
      相关资源
      最近更新 更多