Friday 23 March 2012

CakePHP: Database Associations


Table Associations


CREATE TABLE `posts` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(255) default NULL,
`date` datetime default NULL,
`content` text,
`user_id` int(11) default NULL,
PRIMARY KEY (`id`)
);

CREATE TABLE `comments` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(100) default NULL,
`content` text,
`post_id` int(11) default NULL,
PRIMARY KEY (`id`)
);

Git: Most oftenly used commands


Global setup:

 Set up git
  git config --global user.name "sonu"
  git config --global user.email sonukr666@gmail.com

Next steps:

  mkdir dfd
  cd dfd
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:sahilsonu/dfd.git
  git push -u origin master

CakePhp : Naming Conventions

Naming Conventions:


Naming Controllers:

Each controller name must match a database table name.
If you decide to create controllers with names other than tables of the database, you should actually not create a controller but use a component instead .

The names of database tables as well as controllers are lowercase and in plural form.
eg.  Table name: orders, special_orders