PHP and MySQL 5 bit fields

While debugging some PHP code the other night I came across a particularly strange problem with MySQL Bit fields.

I was returning a query with some bit fields into my class but the it was not returning true or false when I switched the data.

A bit of hunting and it turned out the that it was being returned as a binary type and after a few failed attempts to convert it to an integer or boolean on the PHP side I found this bug report on it.

So the moral of the story is if you are selecting BIT types from a mysql DB in PHP don't do this:

SELECT myBit
FROM tbl_example
WHERE id = 1

Instead cast the bit to an integer in MySQL like so:

SELECT CAST(myBit AS unsigned integer) AS myBit,
FROM tbl_example
WHERE id = 1

Voila, it works like expected.

Cheers, Mark Lynch

Job Vacancy Sydney AU - Graduate or Junior OO Programmer

We're looking for a Computer Science Graduate or similar with strong Object Oriented programming skills and the ability to grasp cutting edge technologies quickly.

If you are looking to work with the latest technogies and are a motivated self starter with a positive "can do" attitude this is the job for you. The ability to take problems and deliver solutions is a must.

There will be significant on the job learning as we are always pushing the boundaries and using the latest and greatest technologies. We are currently working on projects using Actionscript/Flex, ColdFusion, PHP, and Javascript, and are leveraging technologies such as VOIP, SMS, Instant Messenger (Jabber XMPP) to deliver cutting edge solutions.

Suitable applicants will have a Bachelors Degree in Computer Science or Engineering, or similar tertiary qualification. Remuneration commensurate with experience.

Responsibilities would include:

  • Developing new functionality for Asterisk and VOIP applications
  • Creating Rich Internet Applications with Adobe Flex
  • Creation of Desktop applications with Adobe AIR
  • Design and development of new Web applications

Must haves:

  • A robust foundation in Object Oriented programming
  • Demonstrated experience in at least one OO language
  • Motivation to learn and push the boundaries
  • Understanding of XHTML and CSS

Preferable:

  • Experience with PHP, ColdFusion, Farcry CMS, XML, Web Standards etc
  • Competency using linux-based tools (SSH, bash, etc)
  • Familiar with using source control tools (Subversion, etc)
  • Familiarity with Actionscript or Flash

This role may be full time, part-time or on a contract basis depending on the candidates skills and experience. You will be working in a casual workplace with flexible hours in the centre of Sydney.

If this sounds like the job for you email your resume to mark@lynchconsulting.com.au if interested - no agencies please.

Open source story

I've been using and promoting open source software for many years and recently I've been beginning to give back to the community.

It's not because I feel bad about taking and not giving back - for me it's primarily about efficiency.

I don't like reinventing the wheel and I like the fact that the Open Source model allows you to reuse others work, and they can reuse your work. Whereas in the the proprietary (capitalist) model I've seen huge inefficiencies of the same code being rewritten because the code is not available to use (for licensing or other reasons).

To this end when I needed a simple LDAP address book management tool for a client a couple of years back I had a look on the web and the only one's I could find were some unmaintained applications that didn't work.

So I convinced the client to let me write the code (at a reduced rate) on the understanding that I would release the code open source. One of the reasons I used was that if we got other people using it then they may add improvements and it would be a win-win situation.

This I duly did and Contact 0.1 was released on 24th April 2005. Exactly 2 months later I released Contact 0.2. At this point the application did pretty much everything that the client needed and some more on top.

Over the next 18 months or so I received the odd email from different places including Philadelphia and Western Australia from people who were using the application. I included a couple of minor changes but not much more.

Then recently I was contacted by another open source developer (Christian Boulanger) who had been using it and wished to contribute to it but thought that it could do with being put into the cakePHP framework. I agreed but didn't have the time to work on it.

A couple of weeks later Christian sent me a copy of my code ported to cakePHP. This reignited my interest and has set up Contact to be significantly improved.

I've set up a new Subversion repository for it - as well as a Trac Project to make it easier for us to collaborate and for others to see progress.

So all in all I'm delighted that my project is useful to other people and happy the code will live beyond it's initial life expectancy of a single piece of custom code.

Here's looking forward to Contact 0.5

Cheers, Mark

Nibbler - Simple Server Monitor - 0.2 release

Nibbler 0.2 has been released earlier this week (4-Oct-06) with good progress on the service logging area. The changes are below:

Changes:

  • Saving status of services is now working
  • History page now working in limited fashion
  • Add user agent field to HTTP connection displays as "Nibbler Server Monitor (http://nibbler.sourceforge.net/)"
I've recently come across cakePHP and am looking at migrating it to use it as it will make the development of nibbler simpler and quicker. It will also enable the advanced features I want in it such as RSS feeds, AJAX interface and linking with multiple nibbler servers.

I've already got the base structure in place so hopefully it won't delay the 0.3 release significantly.

Cheers, Mark

Nibbler - Simple Server Monitor - 0.1 release

I've been working on a simple server monitor to make it easy for non guru administrators to monitor servers. It is designed to monitor web servers initially but built in a flexible way to allow extra services to be monitored such as SMTP and SNMP, DB's etc.

I've just put the v0.1 release up and the release notes are below:

NOTE: ALPHA release, not working in any useful way yet for systems monitoring - for developers only

The basic structure of the application is coming together. The following functionality is available:

  • Create/edit/delete hosts
  • Create/edit/delete services (HTTP check only)
  • Run basic http check and return response
Next release is focussed around getting the tracking table populated to report on uptime and server status.

BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.