Welcome Guest, Not a member yet? Register   Sign In
No Model errors reported when calling Global Controller Method
#1

(This post was last modified: 02-15-2019, 10:42 PM by John_Betong.)

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?
Reply
#2

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.
Reply
#3

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB