How to delete

18 views
Skip to first unread message

Roparzh Hemon

unread,
Feb 24, 2016, 7:17:16 AM2/24/16
to redbeanphp

  I'm just beginning to learn RedBeansPHP4, and I'm experimenting with the code below, that implements a toy model
for a blog.
  Here is the point at which I'm stuck : after having created all the data, I want to delete topic number 12. I tried
R::trash('topic',12);

(as in the code below) but it does nothing. What is the proper way to do it ?


require 'rb.php';

R
::setup(  );

$world
=R::dispense ('world');
$world
->name = 'world';
$usernames
=array('Amy','Bob','Cathy');
$users
=array();


for($j1=1;$j1<=3;$j1+=1) {
          $user
= R::dispense('user');
          $username
=$usernames[$j1-1];
          $user
->username = ($username);
          $users
[$j1]=$user;
          $world
->xownUserList[] = $user;
}

for($i1=1;$i1<=3;$i1+=1) {
  $category
= R::dispense('category');
  $catname
='Category'.$i1;
  $category
->catname = ($catname);
  $world
->xownCategoryList[] = $category;
 
for($i2=1;$i2<=3;$i2+=1) {
      $subcat
= R::dispense('subcategory');
      $subcatname
=$catname.'/Subcategory'.$i2;
      $subcat
->subcatname = ($subcatname);
      $category
->xownSubcategoryList[] = $subcat;
     
for($i3=1;$i3<=3;$i3+=1) {
          $topic
= R::dispense('topic');
          $topicname
=$subcatname.'/Topic'.$i3;
          $topic
->topicname = ($topicname);
          $subcat
->xownTopicList[] = $topic;
         
for($i4=1;$i4<=3;$i4+=1) {
              $post
= R::dispense('post');
              $postname
=$topicname.'/Post'.$i4;
              $post
->postname = ($postname);
              $topic
->xownPostList[] = $post;
              $users
[$i4]->xownPostList[] = $post;
       
}
   
}
   
 
}
}


R
::trash('topic',12);
R
::store($world);


Reply all
Reply to author
Forward
0 new messages