Jump to content


Custom Model Ruins the Filtering of Set Relation Data

customModel GroceryCRUDEnterprise ErrorOnSearch ErrorOnFiltering

  • Please log in to reply
2 replies to this topic

#1 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts
  • LocationPhilippines

Posted 03 July 2018 - 12:10 AM

I tried the sample in using the API: setModal from https://www.groceryc...n-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!



#2 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,150 posts
  • LocationLondon

Posted 09 July 2018 - 04: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


Posted Image

#3 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts
  • LocationPhilippines

Posted 09 July 2018 - 11: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







Also tagged with one or more of these keywords: customModel, GroceryCRUDEnterprise, ErrorOnSearch, ErrorOnFiltering

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users