Find MySQL Foreign Keys

January 9th, 2014

Sometimes you need a quick way to find out what foreign key is blocking your action.

[code]SELECT
CONCAT(table_name, ‘.’, column_name) AS ‘foreign key’,
CONCAT(referenced_table_name, ‘.’, referenced_column_name) AS ‘references’
FROM information_schema.key_column_usage
WHERE referenced_table_name IS NOT NULL;[/code]

http://www.conandalton.net/2008/09/list-foreign-key-constraints-in-oracle.html

Javascript Element Properties From Object

December 19th, 2013

How to create a HTML tag, using an object of properties.

[code]$(‘#somediv’).append($(‘<a/>’, {href: ‘#’, id: ‘dothing’, text: ‘Do Thing’}));[/code]

Javascript HTML Fun

December 18th, 2013

Here are some useful Javascript snips for working with form data.

How to get the name of the HTML tag for an element:
[code]this.nodeName.toLowerCase()[/code]

This code will see if we have a map set of inputs (somename[]):
[code]// See if we have a map here
var mapFound = 0;
if (thisName.indexOf(‘[]’) != -1) {
mapFound = 1;
thisName = thisName.replace(/[\[\]’]+/g, ”);
}[/code]

How to take a map of inputs and turn them into a Javascript map type var, and toss the empty ones:
[code]var map = $(thisName).map(function(){
if (this.value != ”) {
return this.value;
} else {
return null;
}
}).get();[/code]

Fun With Automated GIF Generation

October 29th, 2013

Trolling around on the web, found a fun little process for generating animated GIFs: http://rarlindseysmash.com/posts/stupid-programmer-tricks-and-star-wars-gifs

MySQL Views and Explain

October 13th, 2013

This week, I ran into a problem when I was profiling that didn’t seem to be very well documented anywhere. I was trying to profile a query that included a view. The error message that I got when I tried to execute my EXPLAIN was: “EXPLAIN/SHOW can not be issued; lacking privileges for underlying table”

After a lot of flailing out, me and the DBA for this project figured out that in order to be able to execute my EXPLAIN, I needed to have SELECT on the key columns that I was using in my query for the table behind the view. Simple enough, but not something made easy to figure out.

Hopefully this helps someone else figure this out faster.

Happy hunting!

WordPress - Entries (RSS) and Comments (RSS) - © 2011 Ben Dauphinee