BaseModel::update
Usage
void BaseModel::update(array $values, [ string $where_sql = '' ], [ ... $args ])Description
Update multiple records within the database table assigned to the model class.Parameters
Parameter | Required | Type | Description |
---|---|---|---|
$values | Yes | array | An associative array of the columns and values to update records with. |
$where_sql | Yes | string | The WHERE clause within the SQL statement. Can contain placeholders (eg. %s, %i, %b, et al). |
$args | No | desc= |
Examples
Deactivate All Products of Category #16
use App\Demo\Models\Product;
// Update
$cat_id = 16;
Product::update('is_active' => false], 'category_id = %i', $cat_id);