Working with Simple Associations using CakePHP

Posted by Ramsai on Dec 19, 2008 3:30 AM EDT
packtpub.com; By Ahsanul Bari and Anupom Syam
Mail this story
Print this story

Database relationship is hard to maintain even for a mid-sized PHP/MySQL application, particularly, when multiple levels of relationships are involved because complicated SQL queries are needed. CakePHP offers a simple yet powerful feature called 'object relational mapping' or ORM to handle database relationships with ease.In CakePHP, relations between the database tables are defined through association—a way to represent the database table relationship inside CakePHP. Once the associations are defined in models according to the table relationships, we are ready to use its wonderful functionalities. Using CakePHP's ORM, we can save, retrieve, and delete related data into and from different database tables with simplicity, in a better way—no need to write complex SQL queries with multiple JOINs anymore!

In this article by Ahsanul Bari and Anupom Syam, we will have a deep look at various types of associations and their uses. In particular, the purpose of this chapter is to learn:

  • How to figure out association types from database table relations
  • How to define different types of associations in CakePHP models
  • How to utilize the association for fetching related model data
  • How to relate associated data while saving

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: MySQL, PHP

« Return to the newswire homepage

This topic does not have any threads posted yet!

You cannot post until you login.