CodeIgniter Forums
How to delete a table when i know half name of the table in ci - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: How to delete a table when i know half name of the table in ci (/showthread.php?tid=828)



How to delete a table when i know half name of the table in ci - Thamaraiselvam - 01-21-2015

i have a tables combination of two names , these two names are in different table like friend 1 and friend 2 . when i delete one name from the friend 1 or friend 2, i should delete the combination table . now i know only the half of the name of the table example : the table name is thamaraiselvam_kuppuraj when i delete kuppuraj from the friends 2 table. i should delete thamaraiselvam_kuppuraj table also. how to write query for this?

$this->dbforge->drop_table('table name');

can i use above query with some modification?


RE: How to delete a table when i know half name of the table in ci - sv3tli0 - 01-21-2015

Its not possible..
Think this way:
if you have : "thamaraiselvam_kuppuraj" , "thamaraiselvam_kuppuraj2", "thamaraiselvam2_kuppuraj" any try to match them can drop more tables than you need to be dropped ..
Better make a new table where to list all tables combinations and when you delete 1 name it will use this new table to catch tables to be dropped..


RE: How to delete a table when i know half name of the table in ci - Thamaraiselvam - 01-21-2015

(01-21-2015, 01:59 AM)sv3tli0 Wrote: Its not possible..
Think this way:
if you have : "thamaraiselvam_kuppuraj" , "thamaraiselvam_kuppuraj2", "thamaraiselvam2_kuppuraj" any try to match them can drop more tables than you need to be dropped ..
Better make a new table where to list all tables combinations and when you delete 1 name it will use this new table to catch tables to be dropped..

Thank you Big Grin Big Grin


RE: How to delete a table when i know half name of the table in ci - ivantcholakov - 01-21-2015

Argh... You should have known 90% of the table name. :-)


RE: How to delete a table when i know half name of the table in ci - CroNiX - 01-21-2015

It sounds like you don't have a truly relational database set up. There shouldn't be "friend1" and "friend2" tables. There should be one table, friends, probably with an ID, user_id and a friend_id, which can store as many friends per user as you need.