Permalink
Browse files

code comment and README.md

  • Loading branch information...
1 parent daa8a61 commit c572785c3c127e683b5ad9675b12ded73f56196a @mstdokumaci committed May 22, 2012
Showing with 27 additions and 0 deletions.
  1. +3 −0 README.md
  2. +7 −0 sample/social/list.php
  3. +8 −0 sample/social/model.php
  4. +9 −0 sample/social/readme.md
View
@@ -38,3 +38,6 @@ For a sneak peak, follow the document.
$adb->relate('user', 'friend', $uid1, $uid2);
+### Removing items
+
+ $adb->delete('user', $uid1);
@@ -3,12 +3,14 @@
require_once('config.php');
foreach ($adb->id_list('user') as $id) {
+ // load user
$user=$adb->load('user', $id);
echo '<h1>' . $user['name'] . '</h1>' . "\n";
echo '<h2>Friends: </h1>' . "\n";
echo '<ul>' . "\n";
foreach ($user['friend'] as $fid) {
+ // load friend of user
$friend=$adb->load('user', $fid);
echo '<li>' . $friend['name'] . '</li>' . "\n";
}
@@ -17,9 +19,11 @@
echo '<h2>Posts: </h1>' . "\n";
echo '<ul>' . "\n";
foreach ($user['post'] as $pid) {
+ //load post of user
$post=$adb->load('post', $pid);
$likers=array();
foreach ($post['liker'] as $liker) {
+ // load liker of post
$liker=$adb->load('user', $liker);
$likers[]=$liker['name'];
}
@@ -31,10 +35,13 @@
echo '<h3>Comments: </h1>' . "\n";
echo '<ul>' . "\n";
foreach ($post['comment'] as $cid) {
+ // load comment of post
$comment=$adb->load('comment', $cid);
+ // load commenter of comment
$commenter=$adb->load('user', $comment['writer']);
$likers=array();
foreach ($comment['liker'] as $liker) {
+ // load liker of comment
$liker=$adb->load('user', $liker);
$likers[]=$liker['name'];
}
@@ -1,8 +1,10 @@
<?php
$model=array(
+ // User item definiton
'user'=>array(
'conf'=>array(
+ // 7 digit length for max count of this item
'len'=>7
),
'fields'=>array(
@@ -11,30 +13,36 @@
'name'=>array('len'=>50),
),
'has_many'=>array(
+ // users has many posts and comments
array('type'=>'post', 'foreign_name'=>'writer'),
array('type'=>'comment', 'foreign_name'=>'writer')
),
'many_to_many'=>array(
+ // users can like posts and comments
'liked_post'=>array('type'=>'post', 'foreign_name'=>'liker'),
'liked_comment'=>array('type'=>'comment', 'foreign_name'=>'liker')
),
+ // users can be friend with users
'self_ref'=>array('friend')
),
'post'=>array(
'conf'=>array(
+ // 8 digit length for max count of this item
'len'=>8
),
'fields'=>array(
'text'=>array('len'=>5000),
),
'has_many'=>array(
+ // users can make many comments per post
array('type'=>'comment')
)
),
'comment'=>array(
'conf'=>array(
+ // 10 digit length for max count of this item
'len'=>10
),
'fields'=>array(
@@ -0,0 +1,9 @@
+# social sample
+
+- db and cache configurations are in config.php
+- data model defined in model.php
+- to create db tables run create_tables.php
+- to insert random data run randomize.php
+- to list data in db run list.php
+
+you need to create a writable cache folder if you use files as cache-type.

0 comments on commit c572785

Please sign in to comment.