Back to the Old Binary Stone

Well, in minutes I’ll be working on things for Alt-N and other clients as I get back to the abnormal routines of consultancy. It’s good to be back home and back in action after a trip, it feels ‘normal.’

The Migration Home

Well, Yesterday morning my alarm didn’t go off as planned, which set the tone for the day. However, the drive wasn’t too bad. We passed the following:

  1. St. Louis traffic [25 minute delay]… possibly from Cardinal’s game
  2. An Elvis is Still Alive Evidence Museum
  3. A cow loping down a hill out of control
  4. Several camels
  5. What seemed like millions of cars [Abby lost count after 0]
  6. People who got pulled over to alert me to the fact I needed to slow down
  7. More Semi’s than you could shake your fist at
  8. Zero Starbuck’s in the entire state of Kansas
  9. A Kelp farm [not really]
  10. Cloverdale and Boonviller [two towns on the way to my grandparents’ in Mendocino – only in the Mid-West this time]
  11. A lot of fluids through our mouths and on through our bodies trying to stay awake

And in the end we got home at 12:45. This means that I drove or was ‘on the road’ for 18 hours and 45 minutes. I listened to approximately 6 hours or Veggietales, 2 hours of Paul Simon, 2 hours of John Coltrane, 45 minutes of Crystal Lewis and 30 minutes of Audio Adrenaline. It rained for about 5 hours of our trip which slowed us down further. I also drove for hours and hours of my life through Kansas passing unnumbered museums and ‘porn towns’. Jessica and I dubbed these ‘stops’ porn towns because there was one house and one building and the house housed the loser who ran the building that housed porn.

I could tell that the financial state of America was still not great because of the number of ‘Ad Here’ billboards that were looking for clients to offer their wares via huge posters. One set of billboards that I did notice something good about (I had not noticed this before this trip) was the billboards for Cracker Barrel. Their approach seemed to always be the following:

  1. Place a billboard relatively close to the upcoming Cracker Barrel restaurant, usually within 20 minutes of arrival… keeps your mind moderately fresh with the idea of ‘Country Cooking’ or ‘Comfort. Food.’
  2. Always have the billboard display clear, simple directions at the bottom in easy to read lettering
  3. Always have an easy to see sign in the air as you approach the town/city

This little bit of marketing and clear thinking impressed me. Our waitress there at lunch was cheerful and glad to help, she smiled and laughed several times making it easy to interact with her when needed. Clearly a good game plan for a business even if the food there is not always what I’m after. The distracted ‘store’ at the front is brilliant and probably garners Cracker Barrel multiple millions of dollars extra every year.

OK, I’m done now 🙂 I’m going to head out to church soon, which I didn’t think I’d get to do today.

Alarming

This morning my alarm didn’t go off when I expected it to, so we’re getting onto the road late 🙁 I set it for 5:00 AM ROCKY MOUNTAIN TIME [We’re in Indiana]. Such is life. We’ll still get in at a reasonable hour. I’ll let you know when that happens.

StatTraq Taking Off

A lot of people are starting to use or at least download StatTraq, which is cool. If you’re included in this group please email me and let me know if you’ve got any suggestions or feature requests. I’ve been on vacation for a week and when I get back next week an update will be released shortly. I’ve added a few features to the Summary page including:

  1. Re-arranging the layout to allow for clearer data presentation
  2. Adding the title to the page views section and making them links to the article itself
  3. Added linke to Google, Yahoo! and MSN to the Search Term results to allow you to click on the search term and see what gets returned by the corresponding search engine

There’s still more to do, but I’m excited about all of the positive responses. Keep your ideas and comments rolling in.

White Castle Update Update Update

I’m thinking that the title of this post reminds me too much of 1984 with the double-speak where they had trimmed the ‘government publishing language’ down to 140 words (I don’t remember exactly how many). If you wanted to write a negative statement you would say ‘good good’ where repetition negated the original positive meaning into a negative and bad meaning. That being said, rest assured that this morning I was still sad that I ate White Castle 🙂

Writing a WordPress Plugin: Part II

In Part One we discussed adding actions and filters to WordPress as an initial step in writing a WordPress plugin. These hooks into the WordPress API allow your code to be called by WordPress as certain events and code are generated.
However, your plugin may need to access the WordPress database to use WordPress’ data for outputting various pieces of information. WordPress’ $wpdb object is perfect for the job and easy to use.

The WordPress database interaction object is created in the WordPress code for you, so all you’ll need to do is import it into your functions that are called by WordPress like so:

function suckMyDatabasesBrainsOut(){
global $wpdb, $tableposts;
// other code here to make the world a better place
}

You’ll also need to import the database name that you’ll need access to because WordPress 1.2 uses variables to hold the database names. The database names are dynamic because you can have multiple WordPress installations and each installation has a different prefix. The list of default tables are found in the wp-settings.php file:

  • $tableposts
  • $tableusers
  • $tablesettings
  • $tablecategories
  • $tablepost2cat
  • $tablecomments
  • $tablelinks
  • $tablelinkcategories
  • $tableoptions
  • $tableoptiontypes
  • $tableoptionvalues
  • $tableoptiongroups
  • $tableoptiongroup_options
  • $tablepostmeta

You’ll have to determine what table has the data you’re after. I recommend using PHPMyAdmin to look at the information in your database.

OK, so you’ve got access in your plugin, but now you need data, because access is [only] half the battle (to mutilate G.I. Joe). You can use the following functions to get data from WordPress and to control how the WordPress Database object controls output [found in the wp-includes/wp-db.php file]:

$wpdb->escape($string)
Returns a string escaped for safety in MySQL queries.
show_errors()
Turns on WordPress returning MySQL error reporting when errors are encountered.
$wpdb->hide_errors()
Turns off WordPress’ returning MySQL errors when they are encountered.
$wpdb->flush()
Sets cached query results to null
$wpdb->query($SQLQuery)
Used to execute DELETE or UPDATE queries
$wpdb->get_var($SQLQuery, $x, $y)
Use this to get one value from the database, where $x and $y are specific data values. You can call this function with just the query if one result is expected from the query. I have found no documentation regarding the second and third parameter and no where are they used in the WordPress code for version 1.2.
$wpdb->get_row($SQLQuery)
Returns one database result row from a query.
$wpdb->get_col($SQLQuery)
Returns the values from a table column for use as a PHP array.
$wpdb->get_results($SQLQuery, $objectForValueToBeReturnedIn)
Returns the SQL query results in an object that can be accessed by the result column names. If you don’t care what object is used for access you can skip the second parameter.
$wpdb->get_col_info($informationType, $columnOffset)
Returns column meta information for the last column requested. $informationType defaults to 'name' and $columnOffset defaults to -1.

Remember that the data returned by the $wpdb->get_results($SQLQuery)

Notes:It should be noted that WordPress 1.3 changes database access by only requiring you to import the $wpdb global. Currently no information has been published that explains how to add external databases (for example the StatTraq statistics database).

White Castle Update Update

OK, so after about 3 hours I’ve been assimilated and now I must eat White Castle all the time. I think I will buy one every day I love them they’re great. I think they’re better than Chipotle or Ruth’s Chris… NOT! I am chewing gum because the intense smell of my burps makes this really a bad plan for me to repeat it.

In the end I can now say that I have been there, done that and bought the Peptobismol.