We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24714
    • 19 Posts
    I made 2 tables in DB.

    table1.user_id in aggregate to table2.id with cardinality - one

    So everything works perfectly well, i get the exact what i want, Untill!!!

    I decided to delete 1 row (table2.id which was 4) still having table1.user_id with mark 4, so know the query just crashes, after i delete user with user_id = 4, everything start to work again.

    How should I overcome this one, especially need the output kinda "NOT SET" for those users whose user_id can not be found in table2.id ...
      • 3749
      • 24,544 Posts
      Are you sure it’s the query that’s crashing and not the code following it? You often need sanity checks following an xPDO query.

      Feel free to post your code.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 24714
        • 19 Posts
        Actually I overcame this one...
        But i got another question =))
        
        $c = $modx->newQuery('yi_items');
        $c->sortby($sort,$dir);
        
        $yishop = $modx->getCollectionGraph('yi_items','{"yv":{}}', $c);


        So the sorting doesnt work very good for yi_items had to change the code to this
        $c->sortby('yi_items.'.$sort,$dir)


        (then if i define in script to sort some rows from the yi_items table -> it works fine)

        but if I want to sort row frow left joined table ("yv") -> it doesnt work ... of course, you say, it is because of

        $c->sortby('yi_items.'.$sort,$dir)


        well i changed this one to
        if ($sort == 'v_name') {$c->sortby('yv.v_name',$dir);} 
        else {$c->sortby('yi_items.'.$sort,$dir);}


        still nothing’s good

        Actually modx provides not very much info on how working with collectionGraph, as i cant really sort, or save changes to both tables... althoug there is plenty of info on how to get data -> camoon guys, I need CRUD with my joined tables...
          • 24714
          • 19 Posts
          whoa ... strange thing, but the last string - worked for me ... yesterday didnt =)
            • 3749
            • 24,544 Posts
            This should save any changes you make:

            $yishop->save();
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting