Update AS Method

Update AS method is like update method but with unescaped key value pair. This method suitable for update column to column in a table.

This methode is available from SEME Framework version 3.2.2.

Warning

Maybe using escape methode ($this->db->esc('NILAI')) for key value pair is required for prevent SQL injection.

Parameters

Update method has 2 required parameters that is table name and key value pair in array, another parameters are optional. Here is the completed parameters can be used by where methods

$this->db->update_as(string $table_name, array $data_update, [bool $is_debug=0]): bool

$table_name

Fill with table name that will be updated.

$data_update

Contains name and value pair in array. The key is for column name and the value is for new updated value.

$is_debug

Flag for activating debug mode.

Example usage

Here is the examples usage for this method:

<?php
class Blog_Model extends SENE_Model{
  var $tbl = 'blog';
  var $tbl_as = 'b';
  public function __construct(){
	 parent::__construct();
  }
  public function update(){
    $du = array();
    $du['counter'] = '`counter`+1';
    $this->db->where("id",1);
    $this->db->update_as($ths->tbl,$du);
  }
}