Welcome Guest, Not a member yet? Register   Sign In
Will CI 3.x work properly with PHP 8.x?
#5

I have the variable 'terms' used to input search arguments in a form, it is used in 'Model' and 'Controller', CI4. The variable refers to the 'search' field on the form, as shown below:

PHP Code:
<div class="search-container">
 <
form action="/search/allmedia" class="site-search" method="post" name="site-search">
 <
input class="site-search-button" name="wdeda" type="submit" />
 <
input class="site-search-input" name="search" placeholder="Pesquisar" tabindex="1" type="search" />
 </
form>
 </
div

I use the same variable in Model and Controller:

PHP Code:
// Model

public function getNames() {
        $request = \Config\Services::request();
        $db $this->db;
        $terms $request->getVar('search');
        $query $db->table('names')
        ->select('*')
        ->like('name'$terms)
 
    ->orLike('alias'$terms)
 
    ->orLike('alias2'$terms)
 
    ->orderBy('vip''name''alias''asc')
        ->get();
        
        
        
if( $query->getResult() != null ) {
        
        
return $query->getResult();
        
        
} else {
        
        
return null;
        
        
}
    }

// Controller

 
$terms $this->request->getVar('search');        
        
if (empty($terms)) {
            return redirect()->to('/errors/nodata');
            exit;
        
Reply


Messages In This Thread
RE: Will CI 3.x work properly with PHP 8.x? - by wdeda - 05-14-2021, 07:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB