CodeIgniter Forums

Full Version: Combining $userModel->save() with Transactions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I have a pretty complex form that requires multiple table rows to be either inserted, updated or a combination of the two.

I was wondering if it is at all possible to use the $userModel->save() in conjunction with tranaction as this would be a very convenient way of updating my table without the need for a complex rollback function, something like? 

PHP Code:
protected $table      'mytable';
$primaryKey 'id';

$returnType 'array';
$allowedFields = [
public function 
addEditVals($vals) {
    $db db_connect();        
    foreach($vals as $valArray) {
    if ($this->db->transStatus() === FALSE) {
        log_message('notice''[ERROR] {file}-{line}, Failed to Add/Edit Table - '.session('user_name'));
        return false;
        log_message('notice''[SUCCESS] {file}-{line}, Table Added/Updated  - '.session('user_name'));
        return true;

Thanks in advance Smile