<?php namespace App\Models;

use CodeIgniter\Model;

class Install extends Model{

    protected $table = 'install';

    protected $allowedFields = ['id','shop','access_token','install_date','charge_id','active_plan_name','uninstall_date','additional_data'];
    
    
     public function updateByColumns($conditions, $data) {
    
        foreach ($conditions as $column => $value) {
            $this->where($column, $value);
        }

        // Perform the update
        return $this->update(null, $data);
        
    }
    
     public function insertData($data)
    {
    
         return $this->insert($data);
    }
   
   
   public function getByColumns($conditions) {
        // Apply the dynamic conditions
        foreach ($conditions as $column => $value) {
            $this->where($column, $value);
        }

        // Perform the select query and return results
        return $this->findAll();
    }
   
    // Method to delete records based on multiple dynamic columns with AND conditions
    public function deleteByColumns($conditions) {
        // Apply the dynamic conditions
        foreach ($conditions as $column => $value) {
            $this->where($column, $value);
        }

        // Perform the delete operation
        return $this->delete();
    }
    

}