⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

urgent : knowing the field that has been deleted



Freelance-programmer
  • profile picture
  • Member

Posted 23 September 2014 - 21:30 PM

HI

 

my table with multiple fields upload :

 

id

image1

image2

image3

image4

 

 

 

1-how to know the field that has been deleted so i can unlink the appropriate ?

2- how can do a redirection to dashboard/index  after deleting ?

3- how to remove a field from the search  without removing it from list, edit or add ?

 

Thanks


Amit Shah
  • profile picture
  • Member

Posted 25 September 2014 - 03:56 AM

well sorry couldnt really visualize stuf properly - where u asking as what filed got eleted from the table or what file god deleted ...exactly if u can put up a scenario like then we might be able to help you.

 

If you asking as how to know if a field is deleted or not.. well the answer is - the code will fail around the same ... if u have mentioned it hard bound...

Secondly if you asking like on delete of the field - u wana unlink alll the files uploaded - well sorry to say - that aint possible

for a simple reason the program is not hooked to the mysql table for deletion. And the deletion of a field is an manual activity - and once deleted -  how are you going to unlink the files related to that? Cuz u lost in all the values. That process has to be like before deleting the field.

 

What u can do is write a script that will pickup all the files uploaded .. and then on the other end pickup all the entries in all 3 fields .. merge them into a single array and then just extract those values that are not repeated on both array - once u have it.. Bingo - u got the files that are not linked up - so now u can go and delete them.

 

Happy GCing :)


Freelance-programmer
  • profile picture
  • Member

Posted 26 September 2014 - 16:43 PM

Thank you very much for your replay

 

table structure :

 

id

image1

image2

image3

image4

 

 

 

First question :

 

Edit form

 

ImageName1  delete

ImageName2  delete

ImageName3  delete

ImageName4  delete

ImageName1  delete

 

$crud->set_field_upload('image1','assets/uploads/files');

$crud->set_field_upload('image2','assets/uploads/files');

$crud->set_field_upload('image3l','assets/uploads/files');

$crud->set_field_upload('image4l','assets/uploads/files');

 

$crud->callback_before_delete(array($this,'delete_file'));

 

public function  delete($primary_key)
{

$this->db->where('id',$primary_key);
$user = $this->db->get('tableName')->row();
   

   //If File exists

 

  //delete it

}

 

Exemple

 

The user has deleted imageName1 So I need the file name storted in the databse  under image1 fto unlink teh file from files directory

$user = $this->db->get('tableName')->row(); will return files names of file1 , file2, file3 and file4

 

I need a mean to get only the file name  of the file that had been deleted

 

Thank You


Amit Shah
  • profile picture
  • Member

Posted 27 September 2014 - 05:13 AM

i get that / understand .. but 1 thing i like to ensure you - u dont need to bother bout it.. as GC will automatically delete the file for you.

What i believe u can trace back the file being deleted is through the post variables... u can have a look in the same and u will understand as whats being deleted ...

Sorry never worked out on that but this is the way u can know bout things.

 

Happy GCing :)