Welcome Guest, Not a member yet? Register   Sign In
Model not using DBGroup
#1

I searched the forums but it does not appear anyone else is having this issue.

I am using the myth-auth module to provide authentication to my system.  To keep things logically separated, I have a separate database for the authentication module and a separate database for my data.  I have configure the myth-auth module to use the 'default' database group, and I'm trying to configure CodeIgniter 4 to use another  database for the data.  Here is what I have.

.env
Code:
database.default.hostname = localhost
database.default.database = users
database.default.username = mysql
database.default.password = password
database.default.DBDriver = MySQLi

database.publications.hostname = localhost
database.publications.database = publications
database.publications.username = mysql
database.publications.password = password
database.publications.DBDriver = MySQLi

/app/Config/Database.php
PHP Code:
public $default = [
 
'DSN'      => '',
 
'hostname' => 'localhost',
 
'username' => 'mysql',
 
'password' => 'password',
 
'database' => 'users',
 
'DBDriver' => 'MySQLi',
 
'DBPrefix' => '',
 
'pConnect' => false,
 
'DBDebug'  => (ENVIRONMENT !== 'production'),
 
'charset'  => 'utf8',
 
'DBCollat' => 'utf8_general_ci',
 
'swapPre'  => '',
 
'encrypt'  => false,
 
'compress' => false,
 
'strictOn' => false,
 
'failover' => [],
 
'port'    => 3306,
 ];
 public 
$publications = [
 
'DSN'      => '',
 
'hostname' => 'localhost',
 
'username' => 'mysql',
 
'password' => 'password',
 
'database' => 'publications',
 
'DBDriver' => 'MySQLi',
 
'DBPrefix' => '',
 
'pConnect' => false,
 
'DBDebug'  => (ENVIRONMENT !== 'production'),
 
'charset'  => 'utf8',
 
'DBCollat' => 'utf8_general_ci',
 
'swapPre'  => '',
 
'encrypt'  => false,
 
'compress' => false,
 
'strictOn' => false,
 
'failover' => [],
 
'port'    => 3306,
 ]; 

/app/Models/FiscalYearModel.php
PHP Code:
<?php namespace App\Models;

use 
CodeIgniter\Model;

class 
FiscalYearModel extends Model {
  protected $DBGroup  'publications';
  protected $table "FiscalYears";
  protected $primaryKey "FiscalYearID";
  protected $allowedFields = ["FiscalYear"];

  public function getFiscalYear($fiscalYearID) {
    return $this->find($fiscalYearID);
  }

  public function getDBGroup() {
    return $this->DBGroup;
  }

Error Message
mysqli_sql_exception #1146

Table 'users.FiscalYears' doesn't exist
Reply


Messages In This Thread
Model not using DBGroup - by smcintyr - 07-27-2021, 09:02 AM
RE: Model not using DBGroup - by ikesela - 07-27-2021, 12:24 PM
RE: Model not using DBGroup - by smcintyr - 07-27-2021, 01:04 PM
RE: Model not using DBGroup - by InsiteFX - 07-28-2021, 02:58 AM
RE: Model not using DBGroup - by smcintyr - 07-30-2021, 01:02 PM
RE: Model not using DBGroup - by nfaiz - 07-30-2021, 07:46 PM
RE: Model not using DBGroup - by paulbalandan - 07-30-2021, 08:25 PM
RE: Model not using DBGroup - by InsiteFX - 08-01-2021, 01:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB