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


好像 _compile_select 已被弃用 get_compiled_select 未添加到2.1.0。还有其他类似的功能吗?而且我很好奇。有什么特别的理由不加 get_compiled_select() 积极记录和删除 _compile_select


3207
2018-02-10 17:46


起源



答案:


我已经将get_compiled_select()添加到DB_active_rec.php,它似乎没有问题,但我不会删除_compile_select(),因为它在许多其他方法中使用。

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

  • 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;
}

14
2018-05-02 12:34