Skip to content

Tag Archives: Database

Database Admin Controller for Code Igniter and Ext JS 4

I have been using Code Igniter and Ext JS 4 for several months.  In that time, I have created a couple basic templates to display MySQL tables and perform CRUD on those tables.  In addition, I have wanted to create some basic admin screens for the Core Igniter configured databases.  In my configuration, I have multiple databases defined, using Code Igniter’s built-in support for multiple database access.  So, given all of that, I have created a controller that will display all Code Igniter configured databases, list the contained tables, and allow you to display and edit those tables.

Right now the basic template supports simple pagination, as well as Adding, Deleting, and Updating records.  While fairly full-featured, it does not yet handle remote sorting.  In addition, I am sure you will find some minor display issues with data fields that are not your standard integer or varchar.  I will look to address these later.  As an added bonus, the template references Ext JS remotely, so you do not need to install Ext JS 4 for these admin screens to work.  If you are interested in giving Ext JS 4 a try, this is a great way to explore with it.

One feature of this controller is that the panel for the table admin is dynamically generated.  This will allow you to save the created JS file, and modify it to suit your needs.  You can easily create very custom screens from this generated template.

If you would like to see updates, or have any issues, leave me a message here and I will try to address them.

You can download the zip file here.

To install, just add the enclosed files to your controllers and views directory and make sure you have a valid database configured.

MySQL – How to drop all Foreign Keys on a table

I recently was working with a 3rd party DB that was designed well and used lots of foreign keys to enforce referential integrity. Unfortunately, the application that used the DB structure was very poorly written and caused all sorts of problems when the foreign keys were applied. I had to quickly remove all the foreign keys from about 160 tables. The code below will quickly create a script that removes all Foreign Keys from a database.

select concat(‘alter table ‘,table_schema,’.',table_name,’ DROP FOREIGN KEY ‘,constraint_name,’;') from information_schema.table_constraints
where constraint_type=’FOREIGN KEY’;

You can limit by schema by adding the line : AND table_schema rlike ‘Schema Name’

Remember, Foreign keys are only valid when using Innodb, MyISAM does not support foreign keys.

Thanks to Prodromus for providing some of this information.  They have a great site that lists a ton of MySQL tips and tricks.  And, if you are a non-profit, they even perform pro-bono MySQL DBA work.  Look them up.

Terrorist Screening Database – The Terrorist Watch List

I am one of the unfortunate many who’s name is in the FBI’s Terrorist Screening Database, also known as the Terrorist Watch List.  What this means is that when I travel, my name is flagged and I have to be properly identified before I am allowed to get a boarding pass.  In addition, I also am more likely to be singled out for random screening during the normal screening process as you go through security.  When traveling with others, like my family or business associates, they are also more likely to be randomly searched, and often require additional identification at the check-in counter.

Am I a terrorist you ask?  No, I just have the bad luck of having a very common name.  Someone with the same name as me is apparently wanted by the FBI, and I get flagged since our names match. 

The Terrorist Screening Center (TSC) maintains the consolidated database of the names for all known or suspected terrorists, which is known as the Terrorist Screening Database (TSDB).  The Terrorist Screening Center was created on Dec 1, 2003 by Homeland Security Presidential Directive 6 which directed that a center be established to consolidate the government’s approach to terrorism screening and to provide for the appropriate and lawful use of terrorist information in screening processes.  At this time, over 400,00 names are contained in the database, with 5-6% of that number being US Citizens.

Am I upset?  Not really, usually this only causes a short delay (5-10 minutes) when checking-in, and at most airports, the random screening is often faster than waiting in the long security line.  In general, I respect what the government is trying to do, and I subscribe to the motto, better safe than sorry.  I have recently heard that registering with a slightly different variation of your name, like using full middle name, can help prevent getting flagged.  I am going to try that the next time I fly and will comment if it is successful. 

Has anyone else found that they are on the list?  What are your experiences, and are you upset you are on the list?