⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Custom Model Ruins the Filtering of Set Relation Data



larasmith

larasmith
  • profile picture
  • Member

Posted 03 July 2018 - 00:10 AM

I tried the sample in using the API: setModal from https://www.grocerycrud.com/enterprise/api-and-function-list/setModel

and here is the content of my custom model:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

use GroceryCrud\Core\Model;

class m_Signatories extends Model {

    protected $ci;
    protected $db;

    function __construct($databaseConfig) {
        $this->setDatabaseConnection($databaseConfig);

        $this->ci = & get_instance();
        $this->db = $this->ci->db;
    }

    public function extraWhereStatements($select)
    { 
        $select->where('sig.sig_UId = '.$_SESSION['uid'].' or sig.sig_IsShared = 1');
        return $select;
    }
   
}
?>

The where condition was successfully implemented but the filtering or searching is now broken. Refer to the image below:
 

004.png

 

Kindly check on this issue @web-johnny 

 

Thanks!


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 09 July 2018 - 16:43 PM

Hello @larasmith,

 

Can you try the query but with a parenthesis? For example:
 

$select->where('(sig.sig_UId = '.$_SESSION['uid'].' OR sig.sig_IsShared = 1)');

Please let me know if that worked for you.

 

Regards

Johnny


larasmith

larasmith
  • profile picture
  • Member

Posted 09 July 2018 - 23:45 PM

Hello @web-johnny!

 

It did work! :lol: Thank you very much for the support! :lol:

I have other posts too aside from this one I hope you can provide support there too!

Thanks again!

 

Regards,

Lara