Tag: PHP

PHP upgrade on CentOS 5 – Parallels Forums

PHP upgrade on CentOS 5 – Parallels Forums

A short and handy description of how to get PHP upgraded to the latest version while running CentOS with Plesk installed.

Enable your Zend Framework App with Conditional GET!

Enable your Zend Framework App with Conditional GET!

A short article describing how to add support for conditional GET to your Zend Framework project in under 5 minutes. Something that will improve your performance and reduces the load on the server.

Storing Hierarchical Data in a Database

Storing Hierarchical Data in a Database

Whether you want to build your own forum, publish the messages from a mailing list on your Website, or write your own cms: there will be a moment that you'll want to store hierarchical data in a database. And, unless you're using a XML-like database, tables aren't hierarchical; they're just a flat list. You'll have to find a way to translate the hierarchy in a flat file.

Storing trees is a common problem, with multiple solutions. There are two major approaches: the adjacency list model, and the modified preorder tree traversal algorithm.

In this article, we'll explore these two methods of saving hierarchical data.


Method chaining with PHP 5

Since the introduction of PHP 5 and it’s better OO capabilities it is possible to use method chaining. In most modern frameworks, like Zend Framework‘s Zend_Mail for example, it’s widely used.

An example of method chaining from the Zend Framework documentation for the Zend_Mail component looks like this:

$mail = new Zend_Mail();
$mail->setBodyText('This is the content of the mail.')
     ->setFrom('somebody@example.com', 'Some Sender')
     ->addTo('somebody_else@example.com', 'Some Recipient')
     ->setSubject('My own subject')
     ->send();

The code above can also be written like below, without method chaining:

$mail = new Zend_Mail();
$mail->setBodyText('This is the content of the mail.');
$mail->setFrom('somebody@example.com', 'Some Sender');
$mail->addTo('somebody_else@example.com', 'Some Recipient');
$mail->setSubject('My own subject');
$mail->send();

It depends on your likings of which method you want to use, but you can extend your methods with the chaining way without harming the traditional way so in the end the programmer can decide the method he desires. If you want to make the methods ready for it the method simply needs to return the object itself, like so:

public function foo() {
    // ... do something here ...
    return $this;
}

I’ve highlighted line 3 where the magic applies. If you had foo(), bar(), baz() and bat() methods you could then do this:

$myClass->foo()->bar()->baz()->bat();

You may not want or need to do this in any of your code, but the possibility is there if you or any colleague wants to.


pChart – a PHP class to build charts

pChart – a PHP class to build charts

One of the best PHP classes to create beautifull charts with! If you see this you wish you had more clients demanding charts in their applications. You need PHP with GD compiled to be able to use this.

pChart is a PHP class oriented framework designed to create aliased charts. Most of todays chart libraries have a cost, our project is intended to be free. Data can be retrieved from SQL queries, CSV files, or manually provided.


Kohana auth module a better one? download here!

Well.. kohana’s auth module is fine, but it does not work for me…
We programmers just want something we fully understand and most of the time we just write something ourselfs instead of using things that other programmers made.

That’s why i made my own auth module ( used lot of kohana’s auth module ), and i think that everyone could use this one..
The use is very simple, and the code is very easy to understand and extentable.

DOWNLOAD
includes:
-auth module
-sql script

The code works just fine… and when u take a look at the code you will see alot of different kind of databases handling. That is one of the learning curves here for you guys.

Take a look at the database (mysql workbench screenshot):
Kohana auth module (continue reading…)


Copyright © 1996-2010 Re:morse.nl. All rights reserved.
iDream theme by Templates Next | Powered by WordPress