Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] delete row
#21

[eluser]maria clara[/eluser]
[quote author="cahva" date="1266844929"]Do not remove it from function attribute. Remove it from $this->db->delete
Code:
// original
$this->db->delete('maint_company',$data);

// remove $data
$this->db->delete('maint_company');

Same goes for the other $this->db->delete[/quote]

ahh ok got it. i have this code now. but it still not deleting the record. and it was not deleted also in the database

model:

Code:
function delete($data) //Query function use to delete detail user
    {
                
        // Below equals DELETE FROM maint_company WHERE company_id = [company_id]
        $this->db->where('company_id', $data['company_id']);
        $this->db->delete('maint_company');
        
        // Below equals DELETE FROM sec_companyaccess WHERE user_id = [user_id] AND company_id = [company_id]
        //$this->db->where('user_id', $data['user_id']);
        $this->db->where('company_id', $data['company_id']);
        $this->db->delete('sec_companyaccess');
        
       }

controller:

Code:
case $crudConfig['delete']:  
                
                $data['table_name'] = $crudTableName;
                $data['company_id'] = $this->input->post('id'); // and make sure you are posting this data
                //$data['user_id'] = $this->input->post('user_id'); // and make sure you are posting this data
                $this->User->delete($data); //<----- need to pass the company data, the user id, and the table name to the query

                
            }
#22

[eluser]cahva[/eluser]
Check the generated queries. Thats all I can say Smile
#23

[eluser]maria clara[/eluser]
i got the solution. Thanks for the replies. :-)

here:

MODEL:
Code:
function delete($data) //Query function use to delete detail user
    {

        $this->db->where('company_access_id', $data['company_access_id']);
        $this->db->delete('sec_companyaccess');

    }

CONTROLLER:
Code:
$crudTableName = 'erp_sec_companyaccess';
$postConfig['id'] = 'company_access_id';

...some code here

case $crudConfig['delete']:  
                
     $data['table_name'] = $crudTableName;
     $data['company_access_id']=$this->input->post('id'); // and make sure you are posting this data
     $this->User->delete($data); //<----- need to pass the company data, the user id, and the table name to the query
                
     break;

regards,
kahtrina




Theme © iAndrew 2016 - Forum software by © MyBB