This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Learn » eZ Publish » A Quick and Friendly Introduction to...

A Quick and Friendly Introduction to eZPersistentObject

Thursday 18 November 2010 6:11:37 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Step 1: Creating the database table

Let’s start creating a simple database table. In this tutorial we will create a table to store the friendship relations between users. Our database will have only three columns :

  1. user1_id - The id of user 1.
  2. user2_id - The id of the user 2.
  3. status - The status of the friendship.

Every time a user 1 makes a friendship request to a user 2, we store this information in the database. A status 0 means that the request is pending, 1 means that the request was accepted.

Code :

CREATE TABLE tutorial_friendship (
  user1_id int(11) NOT NULL,
  user2_id int(11) NOT NULL,
  STATUS int(11) NOT NULL,
  PRIMARY KEY (user1_id, user2_id)

Here's the PostgreSQL version :

CREATE TABLE tutorial_friendship (
  user1_id integer DEFAULT 0 NOT NULL,
  user2_id integer DEFAULT 0 NOT NULL,
  PRIMARY KEY (user1_id,user2_id)
36 542 Users on board!

Tutorial menu


Printer Friendly version of the full article on one page with plain styles


Proudly Developed with from