Welcome Guest, Not a member yet? Register   Sign In
BUG model common function
#1
Exclamation 

PHP Code:
$Gg model$this->modelGG );
$Gi model$this->modelGI );
var_dump(['gg' => $Gg->table'gi' => $Gi->table])
new 
$this->modelGG;# Worked
new $this->modelGI;# Worked 
print the same name of TABLE   Exclamation
Reply
#2

Hi, what does $this->modelGG and $this->modelGI contain?
Reply
#3

PHP Code:
Crud.php
<?php namespace BAPI\Models\GI;

class Crud extends \CodeIgniter\Model
{
  protected $table = 'gitem';
  protected $primaryKey = 'id';
  protected $returnType = 'array';
  protected $dateFormat = 'date';

  protected $useSoftDeletes = true;
  protected $useTimestamps = true;

Crud.php
<?php namespace BAPI\Models\GG;

class Crud extends \CodeIgniter\Model
{
  protected $table = 'ggroup';
  protected $primaryKey = 'id';
  protected $returnType = 'array';
  protected $dateFormat = 'date';

  protected $useSoftDeletes = true;
  protected $useTimestamps = true
Reply
#4

Oops im sr my bad
It worked!
Im forgot set 2nd ARG to false

$Gg = model( $this->modelGG, false );
$Gi = model( $this->modelGI, false );
var_dump(['gg' => $Gg->table, 'gi' => $Gi->table])
Reply
#5

Okey, what does $this->modelGG contain?

protected = 'BAPI\Models\GG\Crud' or something else?
Reply
#6

It contain
protected $modelGG = '\BAPI\Models\modelGG\Crud';
protected $modelGI = '\BAPI\Models\modelGI\Crud';
Reply
#7

That's odd, it should only be shared on model level, so that you only load GG ones. But it looks like it's picking up something else, maybe the Crud name and assign the previous model again.
Reply
#8

(This post was last modified: 05-12-2020, 12:18 PM by cukikt0302.)

I think so. Seems like forgot to delete the old model or something similar.

PHP Code:
if (($pos strrpos($name'\\')) !== false)
{
    
$class substr($name$pos 1);

I remove all this line it worked Smile
Reply
#9

(This post was last modified: 05-12-2020, 01:17 PM by jreklund.)

Hi could you try the following (revert the changes made to ModelFactory):
PHP Code:
protected $modelGG '\\BAPI\\Models\\modelGG\\Crud';
protected 
$modelGI '\\BAPI\\Models\\modelGI\\Crud'

Do you get the same result?

EDIT: nvm, that should be an escape for \ namespace. Will need to try it out in the weekend.
Reply
#10

(This post was last modified: 05-13-2020, 12:58 PM by jreklund.)

(05-12-2020, 01:10 PM)jreklund Wrote: Hi could you try the following (revert the changes made to ModelFactory):
PHP Code:
protected $modelGG '\\BAPI\\Models\\modelGG\\Crud';
protected 
$modelGI '\\BAPI\\Models\\modelGI\\Crud'

It not working bro
Reply




Theme © iAndrew 2016 - Forum software by © MyBB