Press "Enter" to skip to content

Richy's Random Ramblings

PHP: Zend Session: don’t set it up in the Initalizer

I’ve just wasted a few hours trying to get Zend_Session (part of the PHP Zend Framework) working correctly – previously, on this codebase, I had “rolled my own” cookie and session management system, but I thought I’d do it properly and utilise the Zend_Session system and store it all in a database…

It didn’t work.

Short answer as to why my sessions weren’t saving into the database (even after I switched to using the “default” Zend_Session_SaveHandler_DbTable ) was that I was setting up the session within the “routeStartup” section of Initalizer.php (which is loaded, in MVC fashion, via the bootstrap.php file). Changing bootstrap.php to:

// Prepare the front controller.
$frontController = Zend_Controller_Front::getInstance();
// Change to 'production' parameter under production environemtn
$frontController->registerPlugin(new Initializer('development'));
$maxSessionTime=60*60*24*30*6; // six months
Zend_Session::setSaveHandler(new My_Session_DbTable($maxSessionTime));
Zend_Session::rememberMe($maxSessionTime);

(i.e. take move the session savehandler out of the Initializer, but keep all the $thingy=new Zend_Session_Namespace whereever they are needed) means it started to work.

Most annoying thing: that there was no reason it didn’t work (no warnings, no errors, no documentation hints and no ‘out of place feeling’). Meh.

Personal: You know you are getting old…

  • When Policeman start looking younger
  • You don’t remember being absentminded.
  • You have more patience; but actually, it’s just that you don’t care any more.
  • Your memory is shorter and your complaining is longer.
  • You look forward to a dull evening.
  • You quit trying to hold your stomach in, no matter who walks into the room.
  • Your idea of a night out is sitting on the patio.
  • You begin every other sentence with, “Nowadays…”
  • A ‘late night’ now ends at 11 pm.
  • When the actor playing Doctor Who is younger than you

*sigh*

ClickCartPro: Extracting Sales Figures

If you want to get an idea of the stock you’ve sold using the ClickCartPro UK e-commerce software, then you may find the following SQL query useful. Run in phpMySQL to be able to export the data into a spreadsheet.

SELECT SUM(itemquan) as itemssold, count(*) AS timesordered, itemname, itemnum, itemopts, SUM(itemquan)/COUNT(*) AS average FROM `gbu0_orderitems` WHERE FROM_UNIXTIME(epochorder) BETWEEN ‘2007-01-01’ and ‘2008-12-31’ GROUP BY itemnum,itemopts ORDER BY itemssold DESC

What does this mean?
Well, “SUM(itemquan) AS itemssold” grabs the number of items sold, “count(*) AS timesordered” grabs the number of times that item has actually been ordered (as an order could be for 2 or more items), “itemname, itemnum, itemopts” grabs the items name, item number and the options ordered (handy for sizes), “SUM(itemquan)/COUNT(*) AS average” works out the average number of items per order, “FROM `gbu0_orderitems`” says to look at the order table (ok, I’m not distinguishing between cancelled, pending and completed orders at the moment), “FROM_UNIXTIME(epochorder) BETWEEN ‘2007-01-01’ and ‘2008-12-31′” says to only include orders placed between the 1st of January 2007 and the 31st of December 2008 and “GROUP BY itemnum,itemopts ORDER BY itemssold DESC” means group the items for the counts by the item number and options and then order everything by the number of times sold in decending order.

Paypal, ClickAndBuy, Google Checkout, NoChex and Worldpay Fees

Here’s more a reminder to myself and all figures are based off “base rates” currently provided by the various Payment gateways. Check the figures yourself before using them as they may have changed. I can’t accept any liability for how you use this information.

Paypal charge a fixed fee of £0.20 and 3.4% of each transaction. To figure out the gross figure from the net, use the formula: (net+0.20)/(1-(3.4/100)).

Click and Buy charge a fixed fee of £0.35 and 1.9% of each transaction.

Google Checkout charges a fixed fee of £0.15 and 1.5% of each transaction.

NoChex’s Seller Account charges a fixed fee of £0.20 and 2.9% of each transaction.

Worldpay IMA charges a fixed fee of £0.15 and 3.35% of each transaction (along with a £15 monthly fee and £75 setup fee) [note this is for their current “New Business Deal”, normally they charge £30 per month with a £200 setup fee and £4.50% on credit/charge cards and a flat £0.50 on UK Debit Cards: along with £0.06 per transaction for Fraud Detection]

SecureTrading charges 3.29% on each transaction (subject to a minimum fee of £15 per month with a further £15 per month service fee and a one-off setup fee of £300)

Net: Yahtzee’s Zero Punctuation’s reviews

Ben “Yahtzee” Croshaw has, for around the last year or so, been busy reviewing games under the “Zero Punctuation” monkier for The Escapist. Why that name? Well, he’s a Brit living in Oz and his video reviews have, erm, not a lot of punctuation in them. They are funny, not kid safe, good animation style and they give you a good insight into the games and and…. Meh – it’s nearly 3am in the morning and I just wanted to make a note of the URL so I didn’t have to ask ickle Google every time. It’s http://www.escapistmagazine.com/videos/view/zero-punctuation. There. Job Done. That was nice and simple! 🙂 [And, yes, I just managed to stop myself writing this post in his manner of speaking: it was bad enough when I was reading a review of Mirrors Edge and I read it as he reviewed it]