<?php namespace App\Models;

use CodeIgniter\Model;

class ModelEntity extends Model
{
    protected function generateUpdateSets (array $data, array &$binds) : string {
        $table = $this->table;
        $num_params = count($data);
        $keys = array_keys($data);
        $values = array_values($data);
        $sql = ' SET ';
        for($i = 0; $i < $num_params; $i++) {
            $key = $keys[$i];
            $binds[$key] = $values[$i];
            $sql .= ("$table.$key = :$key:") . ($i === $num_params - 1 ? ' ' : ', ');
        }
        return $sql;
    }
}
