My wife was playing with her site http://nrotxn.com when she installed a theme that required wordpress 3.5 which she hadn’t installed yet. It caused her site to go dead. Fixing it was easy, just run this query to change two rows in the options table back to a theme you do have installed:
UPDATE `wp_options` SET `option_value` = 'twentyten' WHERE `wp_options`.`option_name` = 'template';
UPDATE `wp_options` SET `option_value` = 'twentyten' WHERE `wp_options`.`option_name` = 'stylesheet';
So, if you create a MySQL temporary table in CakePHP, when you try to create a model for that table, it dies, because mysql “Show Tables” doesn’t show temporary tables. To get around this, implement the setSource function in your model.. i.e.
class WholesalerLeadsDataTemp extends AppModel{
var $name = 'WholesalerLeadsDataTemp';
function setSource($tableName) {
$this->setDataSource($this->useDbConfig);
$db =& ConnectionManager::getDataSource($this->useDbConfig);
$db->cacheSources = ($this->cacheSources && $db->cacheSources);
//MySQL Doesn't return temporary tables in the list of tables, so we have to disable this check... (yay...)...
// if ($db->isInterfaceSupported('listSources')) {
// $sources = $db->listSources();
// if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) {
// return $this->cakeError('missingTable', array(array(
// 'className' => $this->alias,
// 'table' => $this->tablePrefix . $tableName,
// 'code' => 500
// )));
// }
// $this->_schema = null;
// }
$this->table = $this->useTable = $tableName;
$this->tableToModel[$this->table] = $this->alias;
$this->schema();
}
}
This awesome site: http://border-radius.com is a really really simple buy awesome border radius generator. It’s very cool.
This is probably the best way I’ve seen to see if a checkbox is checked or not on a click event…
jQuery(this).is(‘:checked’);
Some more awesome jQuery checkbox reference material: http://gaskell.org/determining-if-a-checkbox-is-checked-with-jquery/
Frequently, I am composing css selectors for jQuery dynamicly and need to escape special characters. Especialy in CakePHP when you are trying to get all inputs with a name like “data[Contact][firstName]“.
Karl Varga has a solution - http://kjvarga.blogspot.com/2009/06/jquery-plugin-to-escape-css-selector.html
Thanks Karl!
When mysql stops responding… You can usually bet on finding slow queries to be the culprit.
You can easily enable slow query logging without restarting the server.
Just run:
set global log_slow_queries = ON
This approach isn’t perfect, but for US users, it should be correct 100% of the time.
This blog author describes how he has created a function that uses the Javascript Date objects getTimeZoneOffset method to test various dates and determine what timezone the users computer is likely set to.
Here is the post: http://blog.redfin.com/devblog/2007/08/getting_the_time_zone_from_a_web_browser.html
I really dislike the default wordpress permalink choices. My favorite, is to put this in the custom permalink string: “/%category%/%postname%/”
Joey
A few times now I have developed code for my clients, and when I send it to them, they get an error dealing with output already being sent when something attempts to send a header… You know the classic:
Warning: Cannot modify header information – headers already sent by (output started at /home/a/public_html/wp-admin/includes/plugin.php:1721) in /home/a/public_html/wp-includes/pluggable.php on line 934
This is caused by output having already been sent to the browser, and the headers have to go before the output. Php is smart enough to clear the output buffer if possible before sending headers… So if the output buffer hasn’t been sent to the browser yet because output buffering is enabled php will clear the buffer, and send the header. But if output buffering is disabled, you get an error… And something won’t work right…
So, open up your php.ini file and set output_buffering = Off.
Cheers!
Joey