We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10355
    • 44 Posts
    1.I want to retrieve data from custom tables "modx_custom_addgoods" but nothing happens
    where is my mistake?
    <?php
    $packagepath = $modx->getOption('core_path') . 'components/goods/';
    $modelpath = $packagepath.'model/';
    
    $modx->addPackage('goods',$modelpath);
    
    
    $c = $modx->newQuery('custom_addgoods');
    $c->select('name', 'artikul'); 
    $c->where(array(
    'kamp' => 0,
    'createdby' => 1,
    ));
    $c->sortby('id','ASC');
    $c->limit(10);
    $res = $modx->getCollection('custom_addgoods',$c);
    foreach ($res as $good)
    {
       echo $good->name;
    }
    ?>
    2.What is the difference between $ modx-> getObject and $ modx-> newQuery?
      • 28215
      • 4,149 Posts
      None; make sure you’re using the class name (eg, "addGoods") rather than the table name "custom_addgoods" though.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com

      This discussion is closed to further replies. Keep calm and carry on.