CodeIgniter Forums
find() and findAll() issues - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: find() and findAll() issues (/showthread.php?tid=80839)



find() and findAll() issues - Kolinski - 12-24-2021

Given the following code:
Code:
   $cond = array('id'=>'id', 'lang'=>'lang');
   $ret = $this->model->where($cond)->findAll();
or
   $cond = array('lang'=>'lang');
   $ret = $this->model->where($cond)->find('id');
Both code above working very well when using Google Chrome browser, however return anything (crashes) in all other browsers (IExplorer, Firefox, Edges).

Also, without 'where' clause the code working in all browsers.

Any idea about the issue?

infos: windows 10-64, MariaDB 10.3.15, PHP 7.3.6, CI 4.1.5.

Thanks.


RE: find() and findAll() issues - Kabouter - 12-24-2021

Your problem is probably client side and not server side if it is browser dependent.

Wouldn't more be more logic if you passed variables?

PHP Code:
$cond = array('id'=> $id'lang'=> $lang);

$cond = array('lang'=> $lang); 


This is how I do this in my model

PHP Code:
public function getTest($test_ID)
    {
       
          return 
$this->where(['test_ID'=> $test_ID])->asArray()->findall();
    } 



RE: find() and findAll() issues - InsiteFX - 12-25-2021

PHP Code:
// wrong
$cond = array('id'=>'id''lang'=>'lang');

// correct way
$cond = array('id' => $id'lang' => $lang); 



RE: find() and findAll() issues - Kolinski - 12-25-2021

Thank you all!
Really, both ID and LANG in the real code are variables.
Someone has made a modification to the source code and hasn't documented it properly. The DB return was dependent on info from a cookie. The cookie was just not present in the mentioned browsers, as it was dependent on the visit to a URL for activation.