Есть ли такая функция, как compile select или get compiled select()?

выглядит так:_compile_select устарел и get_compiled_select не добавляется в 2.1.0. Есть ли другие функции, подобные этим двум? А еще мне любопытно. Есть ли какая-то особая причина не добавлять get_compiled_select() для активной записи и удаления _compile_select?

1 ответов


Я добавил 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;
}