• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
the created model does not work 'User'

#1
Hello, friends!

dump: 
Code:
CREATE TABLE IF NOT EXISTS `user` (
 `id_user` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `login` char(50) DEFAULT NULL,
 `name` char(50) DEFAULT NULL,
 `email` char(50) DEFAULT NULL,
 `password` char(255) DEFAULT NULL,
 `ip` char(15) DEFAULT NULL,
 `created_at` int(10) unsigned NOT NULL DEFAULT '0',
 `updated_at` int(10) unsigned NOT NULL DEFAULT '0',  
 PRIMARY KEY (`id_user`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

INSERT INTO `user` (`login`, `name`, `email`, `password`, `ip`,`created_at`,`updated_at`) VALUES
('test','Ivan','aaaa@bbbb.com','e1r1e1','10.0.0.1', 1457950515,1457950515);

app\Models\UserModel.php:
Code:
<?php namespace App\Models;

use CodeIgniter\Model;

class UserModel extends Model
{
    protected $table      = 'user';
       protected $primaryKey = 'id_user';

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

       protected $allowedFields = ['login','name', 'email'];

       protected $useTimestamps = true;
       protected $createdField  = 'created_at';
       protected $updatedField  = 'updated_at';
        protected $dateFormat     = 'int';
        
       protected $validationRules    = [];
       protected $validationMessages = [];
       protected $skipValidation     = false;
}

 
app\Controllers\Home.php :

Code:
<?php namespace App\Controllers;
// *LINK REDACTED*
use CodeIgniter\Controller;
use App\Models\UserModel;

class Home extends BaseController
{
    
    puplic function index()
    {
       
        $userModel = new UserModel();
        $user_id = 1;
        $user = $userModel->find($user_id);
    }
}

Result:

Whoops!

We seem to have hit a snag. Please try again later...

--------------
Help me!
Reply


Messages In This Thread
the created model does not work 'User' - by videoproc - 05-07-2019, 01:52 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.