PHP 5.4 is almost here! Array Dereferencing

10 Jul

Remember how I told you PHP 5.4 was around the corner?
Well, the first alpha release is out and along with Traits there are also other significant enhancements such as the Improved Zend Engine memory usage and performance and the adding of Array dereferencing support.

So, what does “dereferencing” means?
On a previous article called Fluent Interfaces in PHP I explained how objects can be dereferenced in PHP >= 5.
Continue reading

IE, IE and problems with IE

05 Jul

In the year 2011, with FF at version 5 and chrome is stable as always. IE is proud to be V9, yet simple issues make me go bald.

Where is the problem?

Problem lies with IE rendering margin. Here is the situation: we’re building a toolbar, where all the elements basically match one another, there is no fancy sub-nesting or anything like that going on. Everything generic and design to be easily modified, added/removed. Looks fine in Chrome, Safari, FF, yet IE decides that it hates the last portion of the layout and goes berserk. This is what we’re building.
Continue reading

Zend Framework: MySQL Transactions

03 Jul

What is a Database Transaction?
We could define it as a set of independent operations but at the same time related to each other. By definition they must be atomic, consistent, isolated and durable (know as the ACID properties).

Within the transactional tables of MySQL we have the option to disable the autocommit mode and determine when you want to commit (or roll back) a transaction.
Continue reading

Batch Job Scheduling software

03 Jul

There are many term that refer to the same function of runing several programs (“jobs”) on a computer without manual intervention; we could call these batch processing, job scheduler, distributed resource manager or simple batch jobs.

The wiki definition is:

Batch jobs are set up so they can be run to completion without manual intervention, so all input data is preselected through scripts or command-line parameters. This is in contrast to “online” or interactive programs which prompt the user for such input. A program takes a set of data files as input, processes the data, and produces a set of output data files. This operating environment is termed as “batch processing” because the input data are collected into batches of files and are processed in batches by the program.

Continue reading

JSON

03 Jul

JSON (stands for JavaScript Object Notation) is a lightweight text-based standard designed for data interchange. Its MIME type is “application/json”.  It is based on the JavaScript language for representing objects but it is language independent. There is a parser for most of the programming languages.

JSON is built on two structures: a collection of name/value pairs (object) and a list of values (array).

These are the basic data types we can represent on JSON:

  • number
  • string
  • boolean
  • array (list of values enclosed in square brackets)
  • object (collection of key:value pairs enclosed in curly braces)
  • null

This is an example of a JSON string:

1
{"id":1,"name": "Rolando","age": 29,"nicknames": ["Rol","Rolo"]}

A way to interpret a JSON formatted string in JavaScript is by using the eval() function, which was designed to evaluate JavaScript expressions. The result will be a native JavaScript object. There are some unicode characters that are invalid in JavaScript that will require backslash escaping.

The problem using eval() is it’s subject to security vulnerabilities. If the data we are evaluating does not come from a trusted source, it might result in a JavaScript code injection attack.

That is why there are many web browsers that support native JSON encoding/decoding, removing this security issue. Some examples:

  • Firefox 3.5+
  • Internet Explorer 8
  • Google Chrome
  • Safari