Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Symfony]sfPropelActAsNestedSetBehaviorPlugin
Lonas
post
Post #1





Grupa: Zarejestrowani
Postów: 576
Pomógł: 14
Dołączył: 9.11.2005

Ostrzeżenie: (20%)
X----


Takie pytanko mam bo chce trzymac drzewko w bazie danych - uzywam do tego pluginu sfPropelActAsNestedSetBehaviorPlugin

Wszystko mam juz poustawiane ale chyba czegos nie rozumiem.

W dokumentacji sa przyklady dodania drzewka

  1. <?php
  2. $root = new ForumPost();
  3.  $root->makeRoot();
  4.  $root->save();
  5.  
  6.  $p1 = new ForumPost();
  7.  $p1->insertAsFirstChildOf($root);
  8.  $p1->save();
  9.  
  10.  $p2 = new ForumPost();
  11.  $p2->insertAsFirstChildOf($p1);
  12.  $p2->save();
  13.  
  14.  /*
  15.    * Resulting tree :
  16.    *
  17.    * ROOT
  18.    * |- P1
  19.    *    |- P2
  20.    */
  21. ?>


Moje pytanie jest takie wybieram z listy dostepne kategorie - przekazuje id danej kategorii i chce zeby byla to kategoria nadrzedna,
Robe tak :

  1. <?php
  2. $root = new Gallery();
  3.  
  4.        $root->setTitle($request->getParameter('gallery[title]'));
  5.        $root->insertAsFirstChildOf($request->getParameter('gallery[tree_id]'));        
  6.        $root->save();
  7. ?>


ale otrzymuje blad

  1. Catchable fatal error: Argument 2 passed to sfPropelActAsNestedSetBehavior::insertAsFirstChildOf() must be an instance of BaseObject, string given in C:\Program Files\WebServ\httpd\gallery\plugins\sfPropelActAsNestedSetBehaviorPlugin\lib\sfP
    ropelActAsNestedSetBehavior.class.php on line 241


Ten post edytował Lonas 14.11.2008, 15:33:57
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


insertAsFirstChildOf() przyjmuje jako argument obiekt a nie identyfikator obiektu.
Co zresztą masz jak byk napisane:
Cytat
Catchable fatal error: Drugi argument przekazany do sfPropelActAsNestedSetBehavior::insertAsFirstChildOf() musi być obiektem klasy BaseObject a został przekazany string. Dzieje się to w C:\Program Files\WebServ\httpd\gallery\plugins\sfPropelActAsNestedSetBehaviorPlugin\lib\sfPropelActAsNestedSetBehavior.class.php on line 241
Go to the top of the page
+Quote Post
Lonas
post
Post #3





Grupa: Zarejestrowani
Postów: 576
Pomógł: 14
Dołączył: 9.11.2005

Ostrzeżenie: (20%)
X----


Dlaczego kiedy wykonuje kod

  1. <?php
  2. //tworze obiekt nadrzedny
  3.    $root = new GalleryTree();
  4.    $root = GalleryTreePeer::retrieveByPk('2');
  5.    
  6.    //obiekt dziecko
  7.    $p1 = new GalleryTree();
  8.    $p1->insertAsFirstChildOf($root);
  9.    $p1->save();
  10. ?>


caly czas otrzymuje blad
Fatal error: Call to undefined method PropelPDO::createStatement() in C:\Program Files\WebServ\httpd\sf_sandbox\plugins\sfPropelActAsNestedSetBehaviorPlugin\lib\sfPropelActAsNestedSetBehavior.class.php on line 1077

szukalem w google ale nic nie znalazlem.

Tworzac root-a wszystko jest ok

  1. <?php
  2. $root = new GalleryTree();
  3.  $root->makeRoot();
  4.  $root->save();
  5. ?>


a potem jak chce dodac nastepna galaz jest blad :/

Ten post edytował Lonas 10.12.2008, 13:01:30
Go to the top of the page
+Quote Post
sneq
post
Post #4





Grupa: Zarejestrowani
Postów: 8
Pomógł: 0
Dołączył: 6.11.2007
Skąd: Trójmiasto

Ostrzeżenie: (0%)
-----


Cytat(Lonas @ 10.12.2008, 14:00:54 ) *
Dlaczego kiedy wykonuje kod

  1. <?php
  2. //tworze obiekt nadrzedny
  3.    $root = new GalleryTree();
  4.    $root = GalleryTreePeer::retrieveByPk('2');
  5.    
  6.    //obiekt dziecko
  7.    $p1 = new GalleryTree();
  8.    $p1->insertAsFirstChildOf($root);
  9.    $p1->save();
  10. ?>


A zapisać najpierw ROOT'a to co? :-)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 15:11