Christopher Shennan’s Blog

A day in the life of…

Browsing Posts in PHP

Over the last few weeks I have been working on my first wordpress plugin and I am quickly getting to grips with how it all pieces together but I ran into a problem with a rather basic piece of functionality that pretty much rendered the plugin useless until I figured out the issue.

The section I was working on was a form submission (within the wordpress administation) which saved the form values into the database and then redirected the user upon success to another page (using wp_redirect) but this resulted in a blank content pane.

This seems very strange to me as it showed some of the page contents i.e. the header and left navigation but the content pane was completely blank.
continue reading…

Bookmark and Share

A few months ago I posted an article taking about how to get the raw SQL from a Doctrine Query Object but with the release of Symfony 1.3 and Symfony 1.4 it would appear that the code no longer works.  As a result I’ve updated the code to work with Symfony 1.2 – 1.4 and you can find the updated source below:-
continue reading…

Bookmark and Share

csNews Pro

No comments

It’s taken me a while but I’ve finally managed to create the “My Projects” section started although in all likelyhood I’ll not have much time to devote to my projects.

I’ve started off by resurrection an old project that I worked on while I was self employed as Design2Host Ltd.  csNews Pro (formerly V-Desk Newsletter System Pro) has had a few cosmetic details changed (changed the name, removed the licence key limitions) but it’s exactly the same project and it is compatible with the paid version that was original available so you can easily convert from the previous paid version across to the free version when any updates become available.

Feel free to download and play with csNews Pro and feel free to give my any feedback on it.

Bookmark and Share

I am often importing data into a symfony project from an existing site or a CSV file and re-writing this data into the fixtures.yml is usually too complicated or time consuming so I end up writing bespoke import actions.

While I am writing these actions I often find that I have to delete the contents of the MySQL tables as you can never write the routine complete and accurate in one go so as you build it up in smaller steps you find that you have to get rid of the previously old data.

This presented me with 2 problems:-

  • Using DELETE FROM [TABLENAME] does not reset the auto-incrementing fields so if you have anything that is based on the id during the rest of the import then you’re going to have issues.
  • There is a lot of clicking in phpMyAdmin to empty the tables, especially if you forget about the foreign key relationships.

continue reading…

Bookmark and Share

This has been updated to work with Symfony 1.3/1.4 – Please go to the updated article: Raw SQL from Doctrine Query Object – Revised

As my use of Symfony is increasing I find myself frustrated that there doesn’t appear to be an easy way to get the raw SQL from a doctrine query object so I can simply output it and paste it into phpMyAdmin to debug problems with the SQL. I may be wrong about this but as yet I have not found a built in function to perform this operation.

Sure I am able to output the query with the “?” indicating where the necessary values are to go and I can also easily output the array of query parameters so I can substitute these manually but this takes time and it would be much much simpler and quicker to just output the whole query with the substitution already done so it’s a simply copy and paste of the raw SQL from the doctrine query object straight into phpMyAdmin.

I have wrote a quick function to do this and I had meant to post this for a while but I just have not had the chance to get round to it until now.
continue reading…

Bookmark and Share

How many times have you searched for the answer to a problem in Google to find nothing but forums with people who have the same questions but no solutions posted even though the question was raised months, even years earlier?

If you post a question and no-one managed to provide you with an answer do you:-

  • post up your solution when you’ve found it? or
  • simply forget about the post and leave everyone else to figure it out themselves too?

Unfortunately there are a number of people in the latter category (myself included from time to time) and being a web developer means I run into this type of issue more than I would like but, I’ve recently come across yet another great reason why you should go back and answer your own question when you have managed to work out the answer.
continue reading…

Bookmark and Share

Last week I was working away in the office at Line Digital on our latest Symfony based project when our project started giving us a strange error similar to:-

Fatal error: Uncaught exception ’sfConfigurationException’ with message ‘Configuration file "/usr/lib/php/symfony/config/config/core_compile.yml" does not have a registered handler.’ in /usr/lib/php/symfony/config/sfConfigCache.class.php:101

Looking into this a little closer we found that the server had ran out of disk space so after making some space and using “symfony cc” to clear the cache we thought that this would have resolved the problem, however we continued to get the “does not havea  registered handler” message being presented.

continue reading…

Bookmark and Share

One simple thing I keep having to do over and over again is to display the name of the month for a given date.  Normally I have opted to use the first solution that comes to mind which is creating an array with all the month names in it and then when I want to retrieve the month name I just use

$monthName = $aMonth[$monthNum];

However, when I wanted to use PHP to display the month name this time I wanted to see if there was a better solution.

The one I came across was posted on The Code Cookbook and was a simple 1 line statement which was great… simpler, neater and far more elegant than my usual method and it looked like

$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));

Normally I would have been happy with this, however was needing to deal with a month drop down box which didn’t run from January to December but instead ran from November to April but this worked out to be rather simple too.

continue reading…

Bookmark and Share

A few weeks ago the company I work for was changing the server that several client sites are hosted on and this included a website built up using the eCommerce package magento.  All of the migrations went ahead without any problems with the exception of this magento site and it had a couple of us stumped for quite a while.

Process

We followed the basic plan for the migration:-

  • Copy magento files up to the new server
  • Backup the database on the old server and restore on the new server and set the MySQL user
  • Update the “web/unsecure/base_url” and “web/secure/base_url” keys within the core_config_data

This seems to work well for almost everyone we found asking for migration help on the forums but did not work for us.  We even tried updating the /downloader/pear/pear.ini to ensure any additional modules downloaded via Magento Connect would install properly (I have since found out you can simply delete the pear.ini and Magento Connect will rebuild it with the correct paths!)
continue reading…

Bookmark and Share

A few weeks ago I posted a blog entry about problems with Zend clearIdentity() with IE7 and Chrome but I’ve since found that the Zend Framework was not at the root of the problem.  After discussing the problem with a colleague we found that there was a line in the bootstrap.php file like:-

ini_set(’session.cache_limiter’, ‘private’);

continue reading…

Bookmark and Share