We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29861
    • 59 Posts
    I know xPDOCriteria isn’t a cross-plateform solution for db query but I spend a whole day trying to avoid it and didn’t manage to find the right calls.
    Can anyone help me changing the following code (that is working fine) to one using xpdo’s functions where, select, join ... ?
    And if someone knows how to do a mysql condition that look into the user extended field (cf first condition), it’ll help too.

            $locationTable = $this->_modx->getTableName('GaUserLocationLog');
            $userTable = $this->_modx->getTableName('modUser');
            $profileTable = $this->_modx->getTableName('modUserProfile');
            $querystr = "
                SELECT User.* FROM $locationTable AS Loc
                INNER JOIN $userTable User ON User.id = Loc.user_id 
                INNER JOIN $profileTable Profile ON User.id = Profile.id 
                WHERE 
                    ( Profile.extended LIKE '%\"receive_feedback\":\"1\"%' OR Profile.extended NOT LIKE '%receive_feedback%' )
                AND GetDistance(Loc.lat,Loc.long,'$lat','$long')<=$range
                AND User.id <> $user_id
            ";
            $query= new xPDOCriteria($this->_modx,$querystr);
            $users = $this->_modx->getCollection('GaUserLocationLog',$query);
    


    Thanks for any help,

    Thierry