CodeIgniter Forums
No Model errors reported when calling Global Controller Method - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: No Model errors reported when calling Global Controller Method (/thread-72826.html)



No Model errors reported when calling Global Controller Method - John_Betong - 02-15-2019

I am in the process of updating a standalone MySqli/Pdo database that creates SVG Charts (courtesy of HighCharts) and was most surprised when the imported script did not show the Chart (which are shown in the Standalone Version).

The Model:
PHP Code:
<?php 
  declare
(strict_types=1);

 
 namespace App\Models;

 
 error_reporting(-1);
 
 ini_set('display_error$''true');

 
 use CodeIgniter\Model;
 
 // use App\Libraries\L_Super;

 
 // var_dump( get_class_methods('CodeIgniter\Model\M_ci4'));

//=======================================
class M_ci4 extends Model
{

protected 
$db;

//=============================
public dbWriteCsv(
 
 string  $fCsv
 
 int     $iDevId=0
 
 string  $sensorName='NO NAME???'
)
:
int
{
// 
//
// 
 
 $tmp $this->_addHour2UKTime((string) $row->tstamp$lBKK=false);
var_dump($tmp); // returns NULL
die; 
 The addHour2UKTime method is in the Global Controller and not only is it not called but there is no errors or warning shown and var_dump($tmp); returns NULL  !!!!!

I tried adding the following NameSpace to the Model and it is still not called and once again with no errors or warnings shown?

use App\Libraries\L_Super;

I was able to call the method by adding to the Model:

private function addHour2UKTime(...) .

Is this a NameSpace problem or am I expecting too much from the Models?


RE: No Model errors reported when calling Global Controller Method - John_Betong - 02-16-2019

I had a thought and will try the following when I am back on the desktop:

$tmp = $l_super-> _ addHour2UKTime((string) $row->tstamp, $lBKK=false);

I will try with and without the leading underscore.


RE: No Model errors reported when calling Global Controller Method - John_Betong - 02-16-2019

I managed to crack it Smile

Added this to the Model:
use App\Libraries\L_super;

//===============================================
public function __construct(...$params)
{
$this->l_super = new \App\Libraries\L_super();
}//


//============================================================
public function dbWriteCsv(
string $fCsv,
int $iDevId=0,
string $sensorName='NO NAME???'
)
:int
{
// ...
// ...

$tmp = $this->l_super->addHour2UKTime((string) $row->tstamp, $lBKK=false);
var_dump($tmp);
// /var/www/this-is-a-test.com/app/Models/M_ci4.php:102:int 1548567540