Archive for the ‘php’ Category a new side project

June 4, 2013 Leave a comment

Been playing around with another project, a place to put my code snippets:

Check it out:

Categories: php Tags: ,

PHP Framework Benchmark Graph

December 9, 2011 Leave a comment

Was trying to learn more about what’s out there for the PHP Yii framework and found this great graph on github:

Frameworks mentioned:

Categories: php

jquery 1.2 and ajax parameter serialization – passing a php array

November 15, 2011 Leave a comment

php It just sucks when I miss the fine print in the documentation. Recently I’ve been working on a project that passes product parameters to a jquery $.ajax call. The parameters are variable, so I wanted to pass them back to the server in a PHP style array:


This seems to work with jquery 1.3 and greater ( but the system I’m on requires 1.2 for a few other dependencies. So the workaround I used for the problem of passing php style array query string components was as follows:

//static variables to pass to ajax call
var ajaxData = {
  'ProductType' : $('#Type').val(),

//variable product options to pass back, all fields
//are wrapped in a <div id="ProductOptions"> for easy selection
$('#ProductOptions :input').each(function(){
  if($(this).val().length) {
    //the input field names are in PHP array style too: i.e.
     //<input type="text" name="ProductOption[color]" value="444" />
     var name = $(this).attr('name').replace(/.+\[([^\]]+)\]/, "$1");
     ajaxData['ProductOption[' + name + ']'] = $(this).val();

   async: false,
   url: '/admin/ctl_Process.php',
   data: ajaxData,
   success: function(data) {
     //do something here...


Categories: php

php date add – date math compounded

November 15, 2011 Leave a comment

This will probably be an elementary post for most, but recently, I was working on a problem that required determining the expiration of a membership and to write some rules about auto-renewing that membership 10 days prior to expiration. Instead of writing any kind of painful date math, or having to rely on mysql for dateadd functions, strtotime accomplished what I needed:

$now = time();
//expire the membership in a year
$MembershipExpiration = date('Y-m-d', strtotime('+1 year', $now));
//renew the membership 10 days prior to expiration:
$MembershipRenewal = date('Y-m-d', strtotime('+1 year -10 day', $now));

I just threw in the “-10 day” to see what would happen, and those smart cookies who built php already have it all under control.

Categories: mysql, php

void stamp

September 13, 2011 Leave a comment

I just made this today for a project at work. Thought someone else might need this too.

Categories: php, tech

mysql order by in clause

August 8, 2011 Leave a comment

Need to order a query by the results pulled according to the order in the “in” clause:

SELECT * FROM tbl_name WHERE column_a IN ( val1, val2, val3 )
ORDER BY FIELD(column_a, val1, val2, val3);

Categories: mysql, php

I helped out the Rabbi today from the New Shul

April 22, 2011 Leave a comment

We were fixing some parts of the site that was coded in php.

Results are here:

Categories: php