Welcome Guest, Not a member yet? Register   Sign In
Control if query return value
#1

HI i have this query :

Code:
        $this->where('codice_macchina',$codice_bilancia);
        $this->orderBy('id','desc');
        $this->limit(1);

        $bilancia =  $this->first();

        dd($bilancia->countAllResoult());
and return this error:

Code:
Call to a member function countAllResoult() on null

but if i do (by refresh) :

Code:
        $this->where('codice_macchina',$codice_bilancia);
        $this->orderBy('id','desc');
        $this->limit(1);

        $bilancia =  $this->first();

        //dd($bilancia->countAllResoult());

        if(!(is_null($bilancia))) {
         
          echo 'inside if';
          die();

          $bil= explode('_',$bilancia->seriale);
          //$bilancia=5;
          return 'bil_'.$codice_bilancia.'_'.(intval($bil[2]) +1);
       
        }else{
          //$bilancia=4;
          //return $bilancia;
          return 'bil_1'.$codice_bilancia;
        }

It return 'inside if' . Why?
Reply


Messages In This Thread
Control if query return value - by pippuccio76 - 05-11-2023, 03:10 AM
RE: Control if query return value - by JustJohnQ - 05-11-2023, 11:51 AM
RE: Control if query return value - by Mni.day - 05-13-2023, 07:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB