We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16313
    • 71 Posts
    Hello!
    I'd like to select all values from table where field DATETIME is NULL.
    I tried this code, but no luck:
    where=`{"close_date":null}`

    Could you help me?
    I use snippet rowboat but I think, this is no matter
      • 22303 MODX Staff
      • 10,725 Posts
      I think this is a bug in the rbQuery->where() method of Rowboat (or somewhere else in Rowboat). The foreach loop there may be skipping entries that are (int) 0, null, or (bool) false, but whatever the reason it is not respecting the criteria and turning the null into an empty string.

      This, for instance, works perfectly via xPDO/MODX directly:
      <?php
      $users = $modx->getCollection('modUser', $modx->fromJSON('{"remote_key":null}'));
      foreach ($users as $user) {
          var_dump($user->toArray());
      }
      
        • 16313
        • 71 Posts
        Hi opengeek!

        I tried check result from rbQuery->where() and received:
        array(1) { [0]=> array(1) { ["close_date"]=> NULL } }
        This is the function code:
            public function where($criteria) {
                if (is_array($criteria)) {
                    foreach ($criteria as $col => $v) {
                        $this->condition(array($col => $v));
                    }
                } else {
                    $this->condition($criteria);
                }
            }
            protected function condition($criteria) {
                $this->_where[] = $criteria;
                echo var_dump( $this->_where);
            }

        but PDO Statement in debug mode looks not right:
        SELECT * FROM `modx_jobs`
        WHERE `close_date` = ""
        ORDER BY `publishedon` DESC
        LIMIT 3

        so I confused sad
          • 16313
          • 71 Posts
          Anybody help pls.