Skip to content


Word of the Day: “Spalooch”

Yep another delightful new word you can add to your dictionaries. Today’s Buzzword of the day is:

Spalooch

This is the sound that comes when you spill a drink over the edge of your cup onto your clothes.

When it happens, you have been Spalooched..  it is accidental and you can’t spalooch someone.

Posted in Buzzword of the day, General.


Active Module Based Config with Zend Framework

I’ve recently taken to using Zend Framework for a project that I needed to bring up to date. I won’t go into the pros and cons of choosing a framework as there are many much more qualified people who have done a much better job of this subject than I would or could. So Instead I bring to you How I managed to get Active Module Based Configuration within Zend Framework.

The Problem

The Concept I wanted to achieve was to have unique Configuration based upon the module that was active. The Issue with this is that the Bootstrap files and the _init functions for ALL modules are called with no bias as to which module is active. Thus if you created a 3 modules wanted to make menu alterations in one, those alterations will be applied to all. I also wanted to have a a system where if i added extra modules i could just add extra functions to the bootstrap file and it would work in a similar way.

With this in mind, I set about trying to figure out the solution.
Continued…

Posted in PHP, Web Development, Zend Framework.

Tagged with , , , , , , .


Ada Lovelace day 2009 – @LornaJane #ALD09

Today is Ada Lovelace day and as such, we are prompted to write about someone we admire who is female and is involved in technology.

For my Post today I have chosen LornaJane. This stems from many reasons, which over the course of this post I hope to explain.

Continued…

Posted in Personal.

Tagged with , , , .


PHP – Chmod-ed to Windows hell and back

Today has not been a good day.

With various things going wrong, I was please that I had got the file upload code done for a site i’m working on. All I needed to do was make sure that the file had the right permissions and then edit it via GD (via an image editor class i have). Here’s where the trouble started..

I started off by chmoding the file to 777 and then trying to do the resize.. this threw an error with permissions.. so i looked at the file.. Read Only.. strange I thought.

Then I checked the folder and that had a weird green square instead of the checkmark in the checkbox. I tried to remove the read only attribute off of this and hte file.. and it kept coming back.. I went all around hte houses, trying all sorts of techniques .. to no avail.

@auroraeosrose in the PHPWomen IRC channel helped a lot as did Dreis.. (thanks muchly)..

After backing up the files and formatting the drive, to reinstalling the Apache/PHP/MySql stack I was no clearer to the answer as to why the file was always ending up with read only permissions..

Finally it came down to the 1 thing that I had overlooked.. the chmod in the code .. the second parameter was 777. I thought this was correct. Aparrantly not. The second parameter of the chmod function requires an octal code.. thus prefixing the 777 with a 0 (zero) fixed the whole issue.

Boy did i really feel dumb today.

So to wrap up, remember to always pass a FOUR digit code through to chmod or face the annoyance and headache I got today.

Posted in PHP, Web Development.

Tagged with , , , .


MySQL – Conditional Joins

For the most part I’ve used many JOINs in my queries since I leartn how to use them and what they were good for, I much prefer to use an Inner Join over the the Implied join of a WHERE statement.

For those who haven’t yet learnt about JOINs you might be using an implied join in your queries even now… lets take this example:

SELECT table1.field1,table2.field2
FROM table1,table2
WHERE table1.table2_id = table2.IDField

This is an Implied JOIN, you are telling MySQL to get the 2 fields from the 2 tables but only return the ones where the field in table1 is in the field in table2. This works, but using Joins we can improve it.

Ok, Lets take the above example and apply the join mentality to it:

SELECT table1.field1, table2.field2
FROM table1
INNER JOIN table2 on table1.table2_id = table2.IDField

This Links in only the rows that match the ON criteria which in theory should be less than the whole table, which again in theory should make the query faster.

Ok, now we have the JOIN theory out the way, we can get down to what this blog post is actually really all about, Conditional joins. Just Like the WHERE Clause in the SELECT statement you can use AND & OR in the ON part of a JOIN. Usually it’s used to add more constraints to the join, but you can use it in interesting ways,

SELECT table1.field1, table2.field2
FROM table1
INNER JOIN table2 on (table1.table2_id = table2.IDField) AND (table1.itemName = 'foo')

Only JOIN rows that have the matching ID and where the itemName from table1 is equal to foo;

SELECT table1.field1, table2.field2
FROM table1
INNER JOIN table2 on ((table1.table2_id = table2.IDField) AND (table1.itemName = 'foo')) OR (table2.item = 'xx')

Only JOIN rows when the IDs are matching and the itemname is foo, OR when the item in table2 is ‘xx’

Baring in mind that the more complicated you make it, the harder it will be to maintain IT still can be a great method of Reducing the amount of rows that need to be processed.

Hopefully this will help someone, if so or if you have anything to add/point out/criticise etc.. please do comment.. I Don’t Bite.

Posted in MySQL, Web Development.

Tagged with , , , , .


MySQL – Conditional Updates

Just a quick blog post in an update related way,

Recently i’ve needed to toggle multiple rows in a database from 1 value to 1 of possible 2 values dependant on the contents of a field on the row. I wasn’t sure if this was possible, so i asked in #PHPWomen IRC Channel and the general response was that of “Don’t Know”.

So After a backup of the table in question, i decided to try it and see. After all, the worst it could do was just not work. So I tried the following:

UPDATE `tble_name` SET `field1`=IF(`field2`='arbitrary_value',1,0) WHERE `field3`='other_value'

And Voila updated all the rows exactly as needed.

So, It is possible to update all rows in a table, limited to a group and update value based upon a field matching a certain Value.
So all in all MySQL For the WIN!!!

Posted in MySQL, Web Development.

Tagged with , .


jQuery Plugin: Element Existence

Just a Quick little snippet really..

Over at JqueryForDesigners.com @rem mentioned about checking if an element exists or not, I’ve been doing this for some time using the following snippet:

jQuery.fn.exists = function() {
    return (this.length > 0);
};

to use it you can now do this:

if ($('#elem').exists()) { /* do something */ }

Hope this is helpful to some people

Posted in Javascript, Web Development, jQuery Plugins.

Tagged with , , .


Zend Framework – Getting Single Components

Recently i was looking at implementing some caching to recent websites.. 1 to improve load times as well as a possibility to improve the way that my “Framework” works.

I had just recently looked over Rob Allen’s (@Akrabat http://akrabat.com/) PHP Nw 08 Conference Talk on “First Steps with Zend Framework”. As I had not been really feeling all that great at the conference itself, I was glad to be able to watch teh recorded version on the web. During the 1st segment of the talk, Rob described how zend cache was his first foray into the Zend Framework and this lead me onto how I was thinking about how the best way to implement the caching on my site(s).

So, with this in mind, off I trotted to http://framework.zend.com to grab the Zend Cache component that I wanted to look at. That’s where I hit a snag. It seemed impossible to actually get the components on their own. After about half and hour of scouring the site I still couldn’t find what I wanted, so I Tweeted about my annoyance.. To which I got a couple of replies… the 1st reply came from Richard Chiswell (@rchiswell) who said:

@BinaryKitten You might find the Dependencies list at http://bit.ly/199FYR useful. You could try contacting @CalEvans who wrote a book on ZF

The bit.ly link took me to: http://framework.zend.com/manual/en/requirements.html#requirements.dependencies the listing of the components and their dependencies, Though this was helpful it wasn’t really as helpful as the reply i got from Cal Evans (@CalEvans):

@BinaryKitten http://epic.codeutopia.net/pack/

Short Sweet and Wham.. That is exactly what I needed.

Shortly afterwards Richard blogged about this, which in turn made me feel like I should blog about it as well, and oooh look.. So I have.

Posted in PHP, Web Development.

Tagged with , , , , , .


Enhancing your listings with jQuery and QuickSearch

Ever Wanted to have a way to filter/search a list without having to code extra to the serverside? Well maybe the jquery QuickSearch plugin from rikrikrik.com might be the answer

Continued…

Posted in Javascript, Web Development, jQuery Plugins.

Tagged with , , , , .


jQuery image Preloader Plus Callbacks

Hi all, After comments on the previous version by Roberto, I looked into creating callbacks within the code so that it can be used in the way that Roberto had outlined, also I used it as a way to improve my knowledge a little.

After a while I got stuck and figured out a potential method thanks to ai-a in #Javascript on UnderNet, then I spoke to Remy Sharp on Twitter and always being impressed with the work he does on his site (http://www.jqueryfordesigners.com) I asked politely if he would give my code a quick look over. He did so, and so much more besides.

So I present to you now v0.95 of the Image Pre-loader which is now Split into 3 functions (rather than the 2 from before)
Continued…

Posted in Javascript, Web Development, jQuery Plugins.

Tagged with , , , , , .



Get Adobe Flash playerPlugin by wpburn.com wordpress themes