PHP code example of fishingboy / codeigniter-model-base

1. Go to this page and download the library: Download fishingboy/codeigniter-model-base library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fishingboy / codeigniter-model-base example snippets




use fishingboy\ci_model_base\CI_Model_base;

class Users_model extends CI_Model_base
{
    protected $table = "users";
}


$this->load->model('Users_model', 'users_model');

$users = $this->users_model->findBy('email', '[email protected]');

$users = $this->users_model->findBy([
  'role' => 'admin',
  'status' => 'on'
]);

$id = $this->users_model->create([
  'title' => 'sample'
]);

$this->users_model->update($id, [
  'title' => 'sample'
]);

protected $key = 'user_id';

$this->users_model->updateWhere([
  'role' => 'member'
], [
  'status' => 'off'
]);

$this->users_model->delete_where([
  'id' => $id
]);

protected function verifyBeforeCreate(& $params)
{
    return $this->verifyParams($params, [
        'title' => 'eDelete(& $params)
{
    return true;
}

protected function afterCreate($id)
{
    return true;
}

$this->users_model->update($id, [
  'published_at' => 'NOW()'
]);