Welcome Guest, Not a member yet? Register   Sign In
Using CodeIgniter’s Model - difference local server and live server
#1

On my local test environment I can use
PHP Code:
$dossier_first model('EDossier_dossierModel')->where('ID',$ID)->first();
$dossier_find model('EDossier_dossierModel'); //->where('ID',$ID)->first();
$result $dossier_find->find('452');
d($result); 

On my live server this is not longer working - following code is working
PHP Code:
$builder $db->table('edossier_dossier');
 
$builder->select(  '*');
 
$builder->where('ID'452);
 
$dossier $builder->get()->getResultArray(); 

There is one model  where the direct model function is working
PHP Code:
$vraag model('Vragen_app_vragenModel');
 
d($vraag);
 
$dbdata $vraag->find($ID); 


I don't see a difference in the model code - see the models below.
PHP Code:
<?php

namespace app\Models;

use 
CodeIgniter\Model;


//use CodeIgniter\Database\ConnectionInterface;

class Edossier_dossierModel extends Model
{
 
//<editor-fold desc="Class">
 
protected $table 'edossier_dossier';
 protected 
$primaryKey 'ID';
 
 protected 
$returnType 'array';
 protected 
$useSoftDeletes false;
 
 protected 
$allowedFields = [
 
'ID',
 
'EDOSSIER_ID',
 
'NAAM',
 
'ACTIVE',
 
//----------------------
 
'DATE_CREATED',
 
'DATE_LASTCHANGED',
 
'DATE_REMOVED',
 
 ];
 
 protected 
$useTimestamps true;
 protected 
$createdField 'DATE_CREATED';
 protected 
$updatedField 'DATE_LASTCHANGED';
 protected 
$deletedField 'DATE_REMOVED';
 
 protected 
$validationRules = [];
 protected 
$validationMessages = [];
 protected 
$skipValidation false;
 
//</editor-fold>
 //<editor-fold desc="Private Functions">
 
 //</editor-fold>
 
 //<editor-fold desc="Public Functions">
 
 //</editor-fold>


//---------------------------------------------------------
PHP Code:
<?php

namespace app\Models;

use 
CodeIgniter\Model;

//use CodeIgniter\Database\ConnectionInterface;

class Vragen_app_vragenModel extends Model
{
 
//<editor-fold desc="Class">
 
protected $table 'vragen_app_vraag';
 protected 
$primaryKey 'ID';
 
 protected 
$returnType 'array';
 protected 
$useSoftDeletes false;
 
 protected 
$allowedFields = [
 
'ID',
 
'USER_ID',
 
'USER_ID_REGISTRATIE',
 
'DATUM',
 
'UUR_START',
 
'UUR_EINDE',
 
'USER_ID_REGISTRATIE',
 
'UUR_DUUR',
 
'CONTACT',
 
'CONTACT_ANDER',
 
'INHOUD',
 
'VERSLAG',
 
'ACTIEF',
 
//----------------------
 
'DATE_CREATED',
 
'DATE_LASTCHANGED',
 
'DATE_REMOVED',
 
 ];
 
 protected 
$useTimestamps true;
 protected 
$createdField 'DATE_CREATED';
 protected 
$updatedField 'DATE_LASTCHANGED';
 protected 
$deletedField 'DATE_REMOVED';
 
 protected 
$validationRules = [];
 protected 
$validationMessages = [];
 protected 
$skipValidation false;
 
//</editor-fold>
 //<editor-fold desc="Private Functions">
 
 //</editor-fold>
 
 //<editor-fold desc="Public Functions">
 
 //</editor-fold>
 
 
 
 
 
 

Bart Goossens
Project Linde37
[email protected]
Reply
#2

What are the exact model file names?
Are these names exactly the same as the classname?
Reply
#3

[quote="kenjis" pid="411381" dateline="1690622357"]
What are the exact model file names?
Are these names exactly the same as the classname?

They are
Code:
<?php

namespace app\Models;

use CodeIgniter\Model;

//use CodeIgniter\Database\ConnectionInterface;

class Vragen_app_vragenModel extends Model
{
//<editor-fold desc="Class">
protected $table = 'vragen_app_vraag';
protected $primaryKey = 'ID';

protected $returnType = 'array';
protected $useSoftDeletes = true;

Code:
<?php

namespace app\Models;

use CodeIgniter\Model;


//use CodeIgniter\Database\ConnectionInterface;

class Edossier_dossierModel extends Model
{
//<editor-fold desc="Class">
protected $table = 'edossier_dossier';
protected $primaryKey = 'ID';

protected $returnType = 'array';
protected $useSoftDeletes = true;
Bart Goossens
Project Linde37
[email protected]
Reply
#4

(This post was last modified: 08-03-2023, 09:58 PM by kenjis.)

My point is that the class name in the source code and the file name must match exactly.
If they differ by a single letter, it won't work on the Linux server.

You did typo in the namespace:
namespace app\Models;

namespace App\Models;
Reply




Theme © iAndrew 2016 - Forum software by © MyBB