是否有像_compile_select或get_compiled_select()这样的函数?

时间:2012-02-10 17:46:25

标签: codeigniter activerecord codeigniter-2

看起来{@ 1}}已弃用且_compile_select未添加到2.1.0。还有其他类似的功能吗?而且我很好奇。是否有任何特殊原因未将get_compiled_select添加到Active Record并删除get_compiled_select()

1 个答案:

答案 0 :(得分:16)

我已经将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;
}