Tagmysql

Otto on Caching in WordPress

Otto describes why neither page caching, nor persistent object caching are part of the WordPress core, and why they probably never will be. The main reasons are the way WordPress is architected, and the way it is used by the majority. If you’re a person writing a blog that gets less than 1000 hits a day, caching ain’t going to do much for you. And my favorite, about why object cache...

Change the year of all posts in a particular category to 2012

Snippet! Change the year of all posts in a particular category to 2012 with a single SQL query (use with phpMyAdmin or the MySQL command line interface) UPDATE wp_posts AS p JOIN wp_term_relationships AS tr ON tr.object_id = p.id JOIN wp_term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id JOIN wp_terms AS t ON tt.term_id = t.term_id SET p.post_date = REPLACE(p.post_date, YEAR(p...

MySQL Index Hinting

Did you know that you can give a hint to MySQL on which index to use? It’s called Index Hint¬†and can be part of a query where you feel MySQL is doing a wrong choice (although that’s quite unlikely these days.) SELECT * FROM table1 USE INDEX (your_index) WHERE col1 = 1 AND col2 = 2 AND col3 = 3; Where your_index is the name of the index you’d like to use for this query. You can...

Encode Entities Inside PRE Tags

Here’s a little Python script that searches through a given file for pre tags and encodes anything in between. This is useful for when escaping from syntax highlighting plugins and replacing every occurrence of the code shortcode with a pre tag. import re, sys # First argument is the filename, output is filename.encoded filename = sys.argv[1] f = file(filename) output = open('%s.encoded' %...

Regex Replace in MySQL or lib_mysqludf_preg in Ubuntu Linux

I’ve been working a lot with MySQL lately, especially after the major theme and plugin upgrades on my blog. I was dealing with a bunch of content issues like redundant shortcodes and post meta, URL changes, images directories and more. One simple solution would be to grab the database dump, perform various search and replace operations and then feed it back in, and my goal was to do that...

Unreplied Comments in WordPress

Dealing with comments. What a mess! I’ve been quite busy lately so I hadn’t had too much time to reply to each and every comment on my blog, but I’d really love too, seriously! The problem however is that there were times when I replied to somebody, and times when I hadn’t and now with this mess in my comments admin it’s impossible to find out ones I haven’t...

Removing YouTube and Vimeo Shortcodes in WordPress

Quick Tip! If you’ve been using WordPress for a long time you might still be locked in to using a video embed plugin like I was a few hours ago. Yes plugins are great, but these days it’s part of the WordPress core. So how do you get rid of those YouTube and Vimeo shortcodes? I haven’t found an easy way to do it and yes I’m still frustrated with the shortcodes concept in...

How to Generate Quality Data for MySQL

We all had fun with the World Database, Sakila and the others when learning MySQL (see Example Databases), but it sometimes isn’t enough to run certain experiments, benchmarks within your own schema. Of course you could write a script that would generate junk data based on your column types and populate your database with a few thousand entries, but as it turns out, Benjamin Keen already...

From MySQL GUI Tools to MySQL Workbench

I bet that some of you still work with phpMyAdmin and there are plenty of good reasons for that. Perhaps the main reason would be its mobility. Being run by a web server, phpMyAdmin is accessible from anywhere, without installing any extra software, even on the mobiles phones. And the second reason is of course security – most web hosting providers restrict external access to MySQL servers...