Welcome Guest, Not a member yet? Register   Sign In
DBDebug unexpected behavior
#3

Sorry jreklund, I will try to be more explicit. Smile

1) Controller code

PHP Code:
<?php namespace App\Controllers;

use 
CodeIgniter\HTTP\RequestInterface;
use 
CodeIgniter\HTTP\ResponseInterface;

use 
App\Models\TestModel;

class 
Test extends BaseController
{
    public function 
f1()
    {
        echo 
ENVIRONMENT;
        echo 
"------<br>";

        
$tm = new TestModel();
        
$dbres $tm->test();
    }

    
//--------------------------------------------------------------------




2) Model code


PHP Code:
<?php namespace App\Models;

use 
CodeIgniter\Model;

class 
TestModel extends Model
{
    public function test()
    {
        $res $this->db->query("insert into `tw` (`name`) values ('value1');");
        echo "I want to see this print...";
        return $res;
    }



The database only contains one table, named `t1`.
If I use the correct table name,  the output generated is:

Code:
production------<br>I want to see this print...


However, if I run the code as it is in the model (table name voluntary misstaped), the output is:

Code:
production------<br>


I have checked the logs, and the result is a CRITICAL log:


Code:
CRITICAL - 2020-02-15 21:57:53 --> Table 'ci4.tw' doesn't exist
#0 C:\Users\glihm\source\repos\internshipwanted\backend\system\Database\MySQLi\Connection.php(330): mysqli->query('insert into `tw...')
#1 C:\Users\glihm\source\repos\internshipwanted\backend\system\Database\BaseConnection.php(738): CodeIgniter\Database\MySQLi\Connection->execute('insert into `tw...')
#2 C:\Users\glihm\source\repos\internshipwanted\backend\system\Database\BaseConnection.php(666): CodeIgniter\Database\BaseConnection->simpleQuery('insert into `tw...')
#3 C:\Users\glihm\source\repos\internshipwanted\backend\app\Models\TestModel.php(11): CodeIgniter\Database\BaseConnection->query('insert into `tw...')
#4 C:\Users\glihm\source\repos\internshipwanted\backend\app\Controllers\Test.php(19): App\Models\TestModel->test()
#5 C:\Users\glihm\source\repos\internshipwanted\backend\system\CodeIgniter.php(847): App\Controllers\Test->f1()
#6 C:\Users\glihm\source\repos\internshipwanted\backend\system\CodeIgniter.php(338): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Test))
#7 C:\Users\glihm\source\repos\internshipwanted\backend\system\CodeIgniter.php(246): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#8 C:\Users\glihm\source\repos\internshipwanted\backend\public\index.php(45): CodeIgniter\CodeIgniter->run()
#9 {main}


I have checked my CodeIgniter3 code, and I used to check the result of the database query.
In the present case, I can't do it.

The '.env' file is the default one, I have adjust the database password and user only.

Thank you for your lights, and will still looking for a configuration that I am missing.
Reply


Messages In This Thread
DBDebug unexpected behavior - by glihm - 02-15-2020, 02:25 AM
RE: DBDebug unexpected behavior - by jreklund - 02-15-2020, 03:02 AM
RE: DBDebug unexpected behavior - by glihm - 02-15-2020, 09:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB