We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38882
    • 5 Posts
    Hi, i'm have a some problem with xPDO.

    I'm create a table in DB, create schema and etc. All work fine, but if I save some object in DB, I can't get collection after save.

    code:

    $conn = new xPDO('mysql:host=localhost;dbname=mytour;port=3306;charset=utf8','root','');
    $result = $conn->addPackage('review',...);
    $res = $conn->newObject('review',array(
    'fio' => $name,
    'city' => $city,
    'email' => $email,
    'text' => $text,
    'date' => time()
    ));
    $result = $res->save();
    $collect = $conn->getCollection('review',array(
    'type'=>0
    )
    );

    this is a part of code, all variables exists. after run this code in DB created new object, but collection after that is NULL.

    please help and sorry for my english.
      • 1778
      • 659 Posts
      Hello
      Maybe I'm missing something but you don't set any 'type' variable with a value of 0...and you try to get your Collection on this variable named 'type' with a value of 0...
      $conn = new xPDO('mysql:host=localhost;dbname=mytour;port=3306;charset=utf8','root','');
      $result = $conn->addPackage('review',...);
      $res = $conn->newObject('review',array(
      'fio' => $name,
      'city' => $city,
      'email' => $email,
      'text' => $text,
      'date' => time()
      'type' => '0' // did you try to add this ?
      ));
      $result = $res->save();
      $collect = $conn->getCollection('review',array(
      'type'=>0
      )
      );
      

      I suggest to add some debug code to check what is returned...
      Cheers
        • 33968
        • 863 Posts
        That sounds like it could be the problem. You could also just try to retrieve all results without any filter:
        $collect = $conn->getCollection('review');
        
          • 38882
          • 5 Posts
          thank you all. it's was a some other problem, but you help me to find it.