Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 4 model table prefix issue sqlsrv
#1

(This post was last modified: 03-27-2023, 12:30 AM by Uhrien.)

Greetings,
I'm facing a strange issue with codeigniter 4 premodel table prefix with an sqlsrv:
The table i'm looking for is named dbo.pers_RiepilogoPreventivo but when i try to connect with codeigniter premodel it gives me error table 'ica.pers_riepilogopreventivo' doesn't exist adding the "ica." as prefix.
My code is this:
Controller:
PHP Code:
public function getTest3()
    {
      $Edigit_m = new Edigit_m();
      /* $tables = $Edigit_m->lista_tabelle();
      var_dump($tables); */
      $lista $Edigit_m->findAll();
      var_dump($lista);
    
MODEL:
PHP Code:
<?php

namespace App\Models;

use 
CodeIgniter\Model;

class 
Edigit_m extends Model
{
    
    
protected $table'pers_RiepilogoPreventivo';
    protected $primaryKey 'id';
    protected $useAutoIncrement true;
    protected $allowedFields = ['CodCliente''Cliente''Preventivo''NumeroProdotto''DescrizionePreventivo''RigaPrezzoAParte''DescrizionePrezzoAParte'];
    protected $db_edigit;
    

    
public function __construct()
    {    
        $this
->db_edigit = \Config\Database::connect('edigit');      
    
}

and in my db configurations i have no prefix :
PHP Code:
'database' => 'C_base',
        'DBDriver' => 'sqlsrv',
        'DBPrefix' => ''

The strange fact is that if i use query builder instead it load me the table normally:

PHP Code:
public function lista_tabelle()
    {
        $builder $this->db_edigit->table('pers_RiepilogoPreventivo');
        return $builder->get(10)->getResultArray();    

   


any ideas why it add this prefix ".ica"?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB