Author Archive

Managing Software with yum

July 3, 2008

About Packages
Each package is a compressed archive containing product information, program files, icons, documentation and management scripts. Management applications use these files to safely locate, install, update [...]

Create Your Own Mail Script With PHP and IMAP

May 26, 2008

Thanks to PHP, we can check our email account remotely using PHP and its imap_xxx functions, which allow us to communicate with mail servers via IMAP, POP3 or NNTP protocols. In this article Mitchell shows us how to create a completely web-based email checking script which can also delete, send and reply to emails… all [...]

Retrieving data in CakePHP

April 23, 2008

A function to retrieve data in CakePHP is the findAll() model function.
It has the following syntax:
PLAIN TEXT
PHP:

findAll($conditions, $fields, $order, $limit, $page, $recursive);

string $conditions;

array $fields;

string $order;

int $limit;

int $page;

int $recursive;

For example to retrive all the data from a table you will use following:
PLAIN TEXT
PHP:

$this->set($var, $this->Modelname->findAll());

With the “set function” the $var value will be send to the [...]

Transaction behavior

April 8, 2008

Sample model - note the $actsAs
To change default settings do:
Download code
var $actsAs = array(’transaction’ => array(’keyName’ => ‘value’ ;) );

Model Class:
Download code <?php
class Order extends AppModel
{
var $name = ‘Order’;
var $actsAs = array(‘transaction’);
var $hasMany = array(‘OrderDetail’);
?>
Controller Class:
Download code <?php
class OrderController extends AppController {
var $name = ‘Order’;
var $uses = array(‘Order’);
function checkout() {
if(!empty($this->data)) {
$this->Order->begin(); // Start [...]

Creating Reusable Elements with requestAction

April 8, 2008

Creating reusable elements with requestAction is very simple. At the end, we can even cache the element using the new feature in 1.2.
Start of with a simple controller.
Controller Class:
Download code <?php
class PostsController extends AppController {
var $name = ‘Posts’;
function index() {
$posts = $this->Post->findAll();
if(isset($this->params['requested'])) {
return $posts;
}
$this->set(‘posts’, $posts);
}
}
?>
So, we created the Posts controller and we gave it an [...]

Multiple rules of validation per field in CakePHP 1.2

April 7, 2008

On its 1.1 release, CakePHP only allowed us to define one rule of validation per field. If we needed to specify more than one rule, we either had to use some handy extensions to CakePHP that are available, or achieve multiple validation by using the callback method beforeValidate() in our models. CakePHP 1.2 brings us [...]

Browse The File System

March 28, 2008

cd changes derectories

cd 

To your home directory

cd ..

To your home directory

cd -

To your previous working directory

Listing Directory Contents

ls -a 

include hidden files

ls -l

long listing style

ls -R

Recurse through directories

Copying Files & Directories

cp -i source destination

interactive(ask before overwriting file)

cp -R source destination

recursive (recursively copy an entire directory tree)

Creating & Removing Files

touch 

create empty file or update filetimestamps

rm -i 

interactive(ask before removing [...]

Linux File Permission

March 12, 2008

What are permissions?
On a UNIX web server, every single file and folder stored on the hard drive has a set of permissions associated with it, which says who is allowed to do what with the file. Every file (and folder) also has an “owner” and a “group” associated with it. If you created the file, [...]

CakePHP: Data Validation

March 11, 2008

Data Validation
Creating custom validation rules can help to make sure the data in a Model conforms to the business rules of the application, such as passwords can only be eight characters long, user names can only have letters, etc.
The first step to data [...]

Cake Conventions

March 6, 2008

Filenames

Filenames are underscore. As a general rule, if you have a class MyNiftyClass, then in Cake, its file should be named my_nifty_class.php.
So if you find a
snippet you automatically know that:

If it’s a Controller named [...]