Our Blog

Get your web site designed and hosted in 30 days or less!
Click Here to get started

Thank you for visiting the South Bay Media weblog. Here you will find site news & events, various posts related to our core service offerings and other topics such as programming tips and techniques or downloadable source code.

Archive for the ‘Programming’ Category

Codeigniter 1.7.2 Adds a New Class Library (Shopping Cart Class)

Tuesday, December 29th, 2009

The latest release of Codeigniter 1.7.2 adds a new shopping cart class to the library which permits items to be added to a session that stays active while a user is browsing the site.

Like all Codeigniter libraries, initilization is done as follows:

$this->load->library('cart');

And items are added to the cart as follows:

$data = array(
               'id'      => 'sku_123ABC',
               'qty'     => 1,
               'price'   => 39.95,
               'name'    => 'T-Shirt',
               'options' => array('Size' => 'L', 'Color' => 'Red')
            );

$this->cart->insert($data);

Querying Data From a WordPress Blog

Saturday, December 26th, 2009

Some of the latest versions of WordPress use a new taxonomy database schema which can make it a bit tricky to get at and display posts data from MySQL. Here is a query we use to display the latest news and events throughout our site:

SELECT      wp_posts . *
FROM        wp_posts
LEFT        JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
LEFT        JOIN wp_term_relationships ON ( wp_posts.ID = wp_term_relationships.object_id )
LEFT        JOIN wp_term_taxonomy ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id )
WHERE       wp_postmeta.meta_key = "_edit_last"
AND         wp_posts.post_status = "publish"
AND         wp_term_taxonomy.taxonomy = "category"
AND         wp_term_taxonomy.term_id
IN          ( [Put your category ID here] )
ORDER BY    wp_posts.post_date DESC

The IN clause is where you would want to put the ID from the category you want displayed. This query has been tested and works with WordPress version 2.9