We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24374
    • 322 Posts
    The documentation for pdoFetch is very spare. Here's what is shown there:

    $resources = $pdo->getCollection('modResource', array(
        'published' => true,
        'deleted' => false
    ), array(
        'parents' => '1,5,6,-9',
        'includeTVs' => 'tv1, tv2',
        'sortby' => 'id',
        'sortby' => 'asc',
        'limit' => 20,
    ));

    What I can't figure out is, why are there two arrays? And what exactly goes in the first array, versus the second array? I discovered that if I want to search for an ID number, I have to put that in the first array, despite the fact that parent IDs go in the second. What's the logic here? Which site_content fields go in which array? Also, how do I search for content, equivalent to "content LIKE '%something here%'"? I've tried various ways of putting that in, and none of them work. [ed. note: rainbowtiger last edited this post 10 years, 1 month ago.]
      • 4172
      • 5,888 Posts
      the first is where, the second is config, think other scriptProperties

      $resources = $pdo->getCollection('modResource', array(
          'published' => true,
          'deleted' => false,
          'content:LIKE' => '%something here%'
      ), array(
          'parents' => '1,5,6,-9',
          'includeTVs' => 'tv1, tv2',
          'sortby' => 'id',
          'sortby' => 'asc',
          'limit' => 20,
      ));


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 24374
        • 322 Posts
        Quote from: Bruno17 at Aug 19, 2016, 11:33 PM
        the first is where, the second is config, think other scriptProperties

        $resources = $pdo->getCollection('modResource', array(
            'published' => true,
            'deleted' => false,
            'content:LIKE' => '%something here%'
        ), array(
            'parents' => '1,5,6,-9',
            'includeTVs' => 'tv1, tv2',
            'sortby' => 'id',
            'sortby' => 'asc',
            'limit' => 20,
        ));


        I tried content:LIKE exactly as you described, but it didn't work. That's partly why I was feeling confused by it all. BUT, it seems to be working now. I swear I tested it and got no results. No idea what happened.

        Is there any way to do something like "ID=234 OR ID=456"?

        Also, this isn't working to query for a TV value:
        $resources = $pdo->getCollection('modResource', array(
        	'published' => true,
        	'deleted' => false
        ), array(
        	'includeTVs' => 'callresources',
              'where' => "{'callresources:LIKE' : '%href=\"http://www.healthandenvironment.org%'}",
        	'sortby' => 'id'
        ));


        I also tried this:
        $resources = $pdo->getCollection('modResource', array(
        	'published' => true,
        	'deleted' => false
        ), array(
        	'includeTVs' => 'callresources',
              'tvFilters' => 'callresources==%href="http://www.healthandenvironment.org%',
        	'sortby' => 'id'
        ));
        [ed. note: rainbowtiger last edited this post 10 years, 1 month ago.]