CI_DB_active_record::truncate PHP Method

truncate() public method

Compiles a truncate string and runs the query If the database does not support the truncate() command This function maps to "DELETE FROM table"
public truncate ( $table = '' ) : object
return object
    function truncate($table = '')
    {
        if ($table == '') {
            if (!isset($this->ar_from[0])) {
                if ($this->db_debug) {
                    return $this->display_error('db_must_set_table');
                }
                return FALSE;
            }
            $table = $this->ar_from[0];
        } else {
            $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
        }
        $sql = $this->_truncate($table);
        $this->_reset_write();
        return $this->query($sql);
    }

Usage Example

Beispiel #1
0
 protected function _flush()
 {
     $this->_db->truncate($this->_table);
 }