Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 12,999
» Latest member: jinCheon
» Forum threads: 69,050
» Forum posts: 429,764

Full Statistics

Latest Threads
How often do you use the ...
Forum: News & Discussion
1 hour ago
» Replies: 25   » Views: 2,402
controller of _remap seem...
Forum: CodeIgniter 4 Discussion
2 hours ago
» Replies: 3   » Views: 25
Accessing Laravel auth li...
Forum: General Help
3 hours ago
» Replies: 2   » Views: 77
Database error in localho...
Forum: General Help
3 hours ago
» Replies: 1   » Views: 25
How to use a datepicker f...
Forum: General Help
5 hours ago
» Replies: 0   » Views: 25
Issue - Form_Validation >...
Forum: General Help
9 hours ago
» Replies: 2   » Views: 64
Is there some guidance on...
Forum: General Help
11 hours ago
» Replies: 2   » Views: 71
session lock problem
Forum: Libraries & Helpers
Yesterday, 12:29 PM
» Replies: 22   » Views: 694
system check the register...
Forum: General Help
Yesterday, 12:15 PM
» Replies: 5   » Views: 107
Setting $cookieSecure = t...
Forum: CodeIgniter 4 Support
Yesterday, 12:08 PM
» Replies: 0   » Views: 42

 
  Database error in localhost
Posted by: scatman98 - 5 hours ago - Forum: General Help - Replies (1)

i downloaded the website from server to localhost and getting the following error

PHP Code:
A Database Error Occurred
Unable to connect to your database server using the provided settings
.

Filenamecontrollers/Home.php

Line Number
24 


This is whats contained in the Home.php file

PHP Code:
    *         http://example.com/index.php/welcome
     
*    - or -
     *         
http://example.com/index.php/welcome/index
     
*    - or -
     * 
Since this controller is set as the default controller in
     
config/routes.phpit's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see https://codeigniter.com/user_guide/general/urls.html
     */


        public function __construct(){
                parent::__construct();
                 $this->load->helper('
form');
                 $this->load->library('
user_agent');
                 $this->load->library('
paypal_lib');
                 $this->load->model('
Ad_model', 'Ad_user');
                 $this->load->model('
User_model', 'user_model');
              $this->load->library('
VRClient');
                 $this->load->library('
form_validation');
           } 



How do i resolve this?


  How to use a datepicker filter in codeIgniter ?
Posted by: firas - 5 hours ago - Forum: General Help - No Replies

    I want to make a date filter only by year for my event page so people can filter by year so they can see what events are happening by year, but many people are using between date filter which is hard for me to understand, is there anyone can help me build a datepicker filter by year  Huh 

this is my controller : 

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Exhibitions extends CI_Controller {
   
   function __construct() {
       parent::__construct();

       $this->load->helper('general_helper');
       $this->load->helper('date');
       //load pagination library
       $this->load->library('pagination');
       //load post model
       $this->load->model('exhibitions_model');
       //per page limit
       $this->perPage = 10;
   }
   
   public function index(){
       $data = array();
       
       //get rows count
       $conditions['returnType'] = 'count';
       $totalRec = $this->exhibitions_model->getRows($conditions);
       
       //pagination config
       $config['base_url'] = 'http://localhost/demo1/index.php/exhibitions/index';
       $config['uri_segment'] = 3;
       $config['total_rows']  = $totalRec;
       $config['per_page']    = $this->perPage;
       
       //styling
       $config['num_tag_open'] = '<li class="page-item">';
       $config['num_tag_close'] = '</li>';
       $config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="javascript:void(0);">';
       $config['cur_tag_close'] = '</a></li>';
       $config['next_link'] = 'Next';
       $config['prev_link'] = 'Prev';
       $config['next_tag_open'] = '<li class="page-item">';
       $config['next_tag_close'] = '</li>';
       $config['prev_tag_open'] = '<li class="pg-prev">';
       $config['prev_tag_close'] = '</li>';
       $config['first_tag_open'] = '<li>';
       $config['first_tag_close'] = '</li>';
       $config['last_tag_open'] = '<li>';
       $config['last_tag_close'] = '</li>';
       
       //initialize pagination library
       $this->pagination->initialize($config);
       
       //define offset
       $page = $this->uri->segment(3);
       $offset = !$page?0:$page;
       
       //get rows
       $conditions['returnType'] = '';
       $conditions['start'] = $offset;
       $conditions['limit'] = $this->perPage;
       $data['omg_event'] = $this->exhibitions_model->getRows($conditions);
       
       //load the list page view
       
      $this->load->view('templates/header', $data);
     $this->load->view('pages/exhibitions', $data);
      $this->load->view('templates/footer');
   }
   
}


this is my model : 
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Exhibitions_model extends CI_Model{
   /*
    * Get posts
    */
   function getRows($params = array()){
       $this->db->select('*');
       $this->db->from('omg_event');
       $this->db->order_by("date_start", "desc");

       if(array_key_exists("event_id",$params)){
           $this->db->where('event_id',$params['event_id']);
           $query = $this->db->get();
           $result = $query->row_array();
       }else{
           //set start and limit
           if(array_key_exists("start",$params) && array_key_exists("limit",$params)){
               $this->db->limit($params['limit'],$params['start']);
           }elseif(!array_key_exists("start",$params) && array_key_exists("limit",$params)){
               $this->db->limit($params['limit']);
           }
           
           if(array_key_exists("returnType",$params) && $params['returnType'] == 'count'){
               $result = $this->db->count_all_results();
           }else{
               $query = $this->db->get();
               $result = ($query->num_rows() > 0)?$query->result_array():FALSE;
           }
       }

       //return fetched data
       return $result;
   }
}
?>

this is my view : 

Code:
<head>
   <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.css" rel="stylesheet">  
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>  
   <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>

 <!-- jQuery -->
 <script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-1.12.4.js"></script>
 <!-- DataTables -->
 <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>

</head>


<!--===============================
=            Hero Area            =
================================-->

<section class="hero-area bg-1 text-center overly">
 <!-- Container Start -->
 <div class="container">
   <div class="row">
     <div class="col-md-12">
       <!-- Header Contetnt -->
       <div class="content-block">

       <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
       <div class="carousel-inner">
         <div class="carousel-item active">
           <img src="<?php echo base_url() ?>img/ads/ad1.jpg" class="d-block w-100" alt="...">
           <div class="carousel-caption d-none d-md-block">
             <br><br><br><br><br><br>
          <h2>Welcome to Industrial Guide Asia</h2>
           <p>As the annual industrial directory, we provides you up-to-date information from the manufacturing, engineering and trading companies classifying advertisements and listing Products & Services, Brand Titles and Trade Shows. Click the button bellow to see around the website !</p>
         </div>
         </div>

         <div class="carousel-item">
           <img src="<?php echo base_url() ?>img/ads/ad2.jpg" class="d-block w-100" alt="...">
           <div class="carousel-caption d-none d-md-block">
             <br><br><br><br><br><br>
           <h2>Our Website Is upgrading</h2>
           <p>Please bare with us if you encounter some problems when you are visiting our websites. We are fixing our website to give you a good website that will be more corporate and user friendly.  </p>
         </div>  
         </div>

         <div class="carousel-item">
           <img src="<?php echo base_url() ?>img/ads/ad3.gif" class="d-block w-100" alt="...">
           <div class="carousel-caption d-none d-md-block">
             <br><br><br><br><br><br>
             <h2>Don't miss every Event this Year</h2>
             <p>Visit the Event page to check what Event that will be held this Year</p>
           </div>
         </div>
       </div>

       <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
         <span class="carousel-control-prev-icon" aria-hidden="true"></span>
         <span class="sr-only">Previous</span>
       </a>
       <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
         <span class="carousel-control-next-icon" aria-hidden="true"></span>
         <span class="sr-only">Next</span>
       </a>
     </div>
         
       </div>
     
       
     </div>
   </div>
 </div>
 <!-- Container End -->
</section>

    <!--==========================
     Services Section
   ============================-->
       <section class="blog single-blog section">
   <section id="services">
     <div class="container">
         <div class="section-title">
         <h2>EXHIBITIONS ROADSHOWS & SEMINAR</h2>
         <p></p>
       </div>      

<table class="table table-hover">
 <div class="category-search-filter">
         <div class="row">
           <div class="col-md-3">
           Filter
             <div class="widget search p-0">
           <div class="input-group">
              <input type="text" name="order_end_date" value="" class="date-own form-control" id="order-end-date" placeholder="Search">
                <button name="filter_order_filter" type="button" class="btn" id="filter-order-filter" value="filter"><i class="fa fa-search fa-fw"></i></button>
               
             </div>
         </div>


 <script type="text/javascript">
     $('.date-own').datepicker({
        minViewMode: 2,
        format: 'yyyy'
      });
 </script>
           </div>
         </div>
       </div>
<?php if(!empty($omg_event)): foreach($omg_event as $post): ?>
 <thead>
   <tr>
   

   </tr>
 </thead>
 <tbody>
 

   <tr>
     <th scope="row"> <?php if(!empty($post['thumb_img'])){ ?>
       <img src="<?php echo base_url().image('upload/'.$post['thumb_img'],120,53); ?>" alt="">
      <?php } ?></th>
     <td width="15%"><?php echo  dateFormat($post['date_start'], 'd/m/Y').' - '.dateFormat($post['date_end'], 'd/m/Y');?></td>
     <td><?php echo $post['name'];?></td>
     <td><?php echo $post['address'];?></td>
     <td width="15%""><a href="">Send Enquiry</a></td>
   </tr>
 <?php endforeach; else: ?>
               <tr><td colspan="3">Post(s) not found......</td></tr>
               <?php endif; ?>
 </tbody>
</table>

    <!-- Pagination -->
       <nav aria-label="Page navigation example">
         <ul class="pagination">
           <?php echo $this->pagination->create_links(); ?>
         </ul>
       </nav>
     
     </div>    

     

     </div>
   </section><!-- #services -->
 </section>


Exclamation controller of _remap seem to fail.
Posted by: rfrkk - 6 hours ago - Forum: CodeIgniter 4 Discussion - Replies (3)

I build a controller: care.php in App\Controllers\wheels,
for simple testing _remap, the code is as follows.

Assuming the URL is 127.0.0.1/myproject/wheels/care/a1, it will get a1 string.
But,assuming the URL is 127.0.0.1/myproject/wheels/care/bb123, the result will appear "Method App\Controllers\wheels\Care::bb123() does not exis",
it is not as directed to the contentProcess function as I expected,
Please give me help.

PHP Code:
namespace App\Controllers\wheels;
 
use 
CodeIgniter\Controller;
 
class 
Care extends Controller {
 
 
   public function _remap($method, ...$params) {
 
       if (method_exists($this$method)) {
 
           return $this->$method(); // go to a1
 
       }else{
 
            return $this->contentProcess();//go to contrntProcess
 
       }
 
   }
 
 
   protected function contentProcess() {
 
       echo 'contentProcess';
 
   }
 
 
   protected function a1() {
 
       echo "a1";
 
   }
 


  Setting $cookieSecure = true;
Posted by: donpwinston - Yesterday, 12:08 PM - Forum: CodeIgniter 4 Support - No Replies

When I set $cookieSecure = true; in Config/App.php and submit a form I get the following error:

BASEPATH/Security/Security.php at line 193

PHP Code:
186         }
187 
188         
// Do the tokens exist in both the _POST and _COOKIE arrays?
189         if ( ! isset($_POST[$this->CSRFTokenName], $_COOKIE[$this->CSRFCookieName])
190              || $_POST[$this->CSRFTokenName] !== $_COOKIE[$this->CSRFCookieName]
191         // Do the tokens match?
192         {
193             throw new \LogicException('The action you requested is not allowed'403);
194         }
195 
196         
// We kill this since we're done and we don't want to pollute the _POST array
197         unset($_POST[$this->CSRFTokenName]);
198 
199         
// Regenerate on every submission?
200         if ($this->CSRFRegenerate

My form uses the csrf function to create a token. Why is that a problem?


  Is there some guidance on stepping through CI-enabled code?
Posted by: IgniterExplorer - Yesterday, 09:31 AM - Forum: General Help - Replies (2)

Hi,

Along with tutorials and hands-on practice, I'm trying to trace through some of the practice modules I'm using with CodeIgniter.

The problem, as with many libraries, is that it's easy to dig down too deeply.  I'd like to see the flow of e.g. url routing, by watching it happen in my sample code.

Are there any tutorials that run through a debugging session, showing how everything is expanded and translated?



Regards,


  Accessing Laravel auth library from with CI3
Posted by: mrtomtom - Yesterday, 08:16 AM - Forum: General Help - Replies (2)

Hi there,

We need to provide single sign on across two systems, one in Laravel 5 and one in CI3. We need to use the Laravel 5 apps auth library (Spatie Laravel Permission https://www.github.com/spatie/laravel-permission) as the authentication library and be able to check the user permissions from within our CI3 application as well. 

I think this should be possible if we use DB sessions in the Laravel app and then include the Laravel auth library via composer in our CI app? I have not used Laravel much myself, so I was hoping someone might have had some experience accessing Laravel functions within CI3, and could point me in the right direction of how to get started? 


Many thanks


  Model / Entities relation
Posted by: keulu - Yesterday, 03:45 AM - Forum: CodeIgniter 4 Support - No Replies

Hi guys,

on alpha5, I don't think that the entities object is correctly populated.

If my model return an entity or an object and fill the entity.
No fields are casted
No fileds are datamaped
dates aren't muted to TimeObject

Maybe i don't understand something.

2 cases :
I request my model with an object and fill my entity :
$_options in my entity is ignored.

response from my controller :

Code:
{
   "success": true,
   "message": "",
   "data": {
       "firstname": "Darth",
       "lastname": "Vader",
       "username": null,
       "email": "[email protected]",
       "created_at": "2019-02-08 12:27:42",
       "deleted": "0"
   }
}

If i add setter and getter like that in my entity

PHP Code:
public function setCreatedAt(string $dateString)
 
   {
 
       $this->created_at = new Time($dateString'UTC');

 
       return $this;
 
   }

 
   public function getCreatedAt(string $format 'Y-m-d H:i:s')
 
   {
 
       // Convert to CodeIgniter\I18n\Time object
 
       $this->created_at $this->mutateDate($this->created_at);

 
       $timezone $this->timezone ?? app_timezone();

 
       $this->created_at->setTimezone($timezone);

 
       return $this->created_at->format($format);
 
   

my controller return :

Code:
{
   "success": true,
   "message": "",
   "data": {
       "firstname": "Darth",
       "lastname": "Vader",
       "username": null,
       "email": "[email protected]",
       "created_at": {
           "date": "2019-02-08 12:27:42.000000",
           "timezone_type": 3,
           "timezone": "UTC"
       },
       "deleted": "0"
   }
}

OK : created_at is now muted to TimeObject


I request my model with entity in $returnType :

Only fileds are populated setter and getter are not interpreted and $_options is just ignored.

My files :

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

use 
CodeIgniter\Model;

class 
UserModel extends Model
{

 
   /**
     * Model Configuration
     */
 
   protected $table      'users';
 
   protected $primaryKey 'id';
 
   protected $returnType '\App\Entities\User';
 
   protected $allowedFields = ['firstname''lastname''username''email''password'];

 
   protected $useSoftDeletes true;
 
   protected $dateFormat 'datetime';
 
   protected $useTimestamps true;

 
   protected $skipValidation     false;
 
   protected $validationRules    = [
 
       'firstname'    => 'required|min_length[3]',
 
       'lastname'     => 'required|min_length[3]',
 
       'username'     => 'required|alpha_numeric_space|min_length[3]',
 
       'email'        => 'required|valid_email|is_unique[users.email,id,{id}]',
 
       'password'     => 'required|min_length[8]',
 
       // 'password_confirm' => 'required_with[password]|matches[password]'
 
       // 'password_confirm' => 'matches[password]'
 
   ];

 
   protected $validationMessages = [
 
       'email'        => [
 
           'is_unique' => 'Sorry. That email has already been taken. Please choose another.'
 
       ]
 
   ];

 
   protected $afterDelete = ['updateDeletedAt'];


 
   /**
     * Protected & internals methods
     */

 
   protected function updateDeletedAt(array $data)
 
   {
 
       if (! isset($data['id']) ) return $data;

 
       $this->builder()
 
           ->whereIn('id'$data['id'])
 
           ->set(['deleted_at' => date('Y-m-d H:i:s')])
 
           ->update();

 
       return $data;
 
   }


Entities/User.php

PHP Code:
<?php namespace App\Entities;

use 
CodeIgniter\Entity;

class 
User extends Entity
{
 
   protected $id;
 
   public $firstname;
 
   public $lastname;
 
   public $username;
 
   public $email;
 
   protected $password;
 
   public $created_at;
 
   protected $updated_at;
 
   public $deleted;
 
   protected $deleted_at;

 
   protected $_options = [
 
       'datamap' => [
 
           'full_name' => 'username'
 
       ],
 
       'dates' => ['created_at''updated_at''deleted_at'],
 
       'casts' => [
 
           'deleted' => 'boolean'
 
       ],
 
   ];

 
   public function setPassword(string $pass)
 
   {
 
       $this->password password_hash($passPASSWORD_BCRYPT);
 
       return $this;
 
   }



Controller/Users.php
PHP Code:
<?php
namespace App\Controllers;

use 
CodeIgniter\Controller;
use 
CodeIgniter\API\ResponseTrait;

use 
Restserver\Libraries\Format;

use 
App\Models\UserModel;
use 
App\Entities\User;

class 
Users extends Controller
{

 
   /**
     * Entry point for users listing
     */
 
   public function index()
 
   {
 
       $userModel = new UserModel();
 
       $users $userModel->findAll();

 
       $data = [
 
           'success' => true,
 
           'message' => '',
 
           'data' => $users,
 
       ];

 
       return $this->response->setStatusCode(Format::HTTP_OK)->setJSON($data);
 
   }

 
   /**
     * Entry point for specific user
     */
 
   public function show($id)
 
   {
 
       $userModel = new UserModel();
 
       $user $userModel->find($id);
 
       // $user->myDate = $user->created_at->humanize();

 
       if ($user){
 
           $data = [
 
               'success' => true,
 
               'message' => '',
 
               'data' => $user,
 
           ];

 
           return $this->response->setStatusCode(Format::HTTP_OK)->setJSON($data);
 
       }else{
 
           $data = [
 
               'success' => false,
 
               'message' => 'user_not_found',
 
               'data' => []
 
           ];

 
           return $this->response->setStatusCode(Format::HTTP_NOT_FOUND)->setJSON($data);
 
       }

 
   }

 
   /**
     * Entry point for user creation
     */
 
   public function create()
 
   {
 
       $data $this->request->getPost();

 
       // var_dump($data);die;

 
       $userModel = new UserModel();
 
       $userEntity = new User();

 
       if ($userEntity->fill($data)){
 
           if ($userModel->save($userEntity) !== false){

 
               $data = [
 
                   'success' => true,
 
                   'message' => 'resources_created',
 
                   'data' => [],
 
               ];

 
               return $this->response->setStatusCode(Format::HTTP_CREATED)->setJSON($data);
 
           }else{
 
               $data = [
 
                   'success' => false,
 
                   'message' => 'resources_not_created',
 
                   'data' => $userModel->errors(),
 
               ];

 
               return $this->response->setStatusCode(Format::HTTP_NOT_ACCEPTABLE)->setJSON($data);
 
           }
 
       }else{
 
           $data = [
 
               'success' => false,
 
               'message' => 'resource_dont_match',
 
               'data' => [],
 
           ];

 
           return $this->response->setStatusCode(Format::HTTP_BAD_REQUEST)->setJSON($data);
 
       }

 
   }

 
   /**
     * Entry point for user update
     */
 
   public function update($id)
 
   {
 
       $data $this->request->getRawInput();

 
       $userModel = new UserModel();
 
       $userEntity = new User();

 
       if ($userEntity->fill($data)){

 
           if ($userModel->save($userEntity) !== false){
 
               $data = [
 
                   'success' => true,
 
                   'message' => 'resources_updated',
 
                   'data' => ['id' => $id],
 
               ];

 
               return $this->response->setStatusCode(Format::HTTP_OK)->setJSON($data);
 
           }else{
 
               $data = [
 
                   'success' => false,
 
                   'message' => 'resource_not_updated',
 
                   'data' => $userModel->errors(),
 
               ];

 
               return $this->response->setStatusCode(Format::HTTP_NOT_ACCEPTABLE)->setJSON($data);
 
           }
 
       }else{
 
           $data = [
 
               'success' => false,
 
               'message' => 'resource_dont_match',
 
               'data' => [],
 
           ];

 
           return $this->response->setStatusCode(Format::HTTP_BAD_REQUEST)->setJSON($data);
 
       }
 
   }

 
   /**
     * Entry point for user delete
     */
 
   public function delete($id)
 
   {
 
       $userModel = new UserModel();

 
       if ($userModel->delete($id) !== false){
 
           $data = [
 
               'success' => true,
 
               'message' => 'resources_deleted',
 
               'data' => ['id' => $id],
 
           ];

 
           return $this->response->setStatusCode(Format::HTTP_OK)->setJSON($data);
 
       }else{
 
           $data = [
 
               'success' => false,
 
               'message' => 'resource_not_deleted',
 
               'data' => [],
 
           ];

 
           return $this->response->setStatusCode(Format::HTTP_NOT_ACCEPTABLE)->setJSON($data);
 
       }
 
   }


 
   //--------------------------------------------------------------------
 
   // End of file Users.php
 
   //--------------------------------------------------------------------


  problem with CodeIgniter mail function
Posted by: arad.ralami - Yesterday, 02:36 AM - Forum: General Help - Replies (1)

I have a problem when using the Mail function from Code Igniter.

When i try to send out an email i get the following error:


Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.


Code:
From: <>
Return-Path: <>
Reply-To: "" <>
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <4a5f0f56a2652>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Etc.

Guys please tell me how i send an email from a custom widget?


  Custom 404 page working in localhost, but not in live site..
Posted by: HarrysR - 02-19-2019, 01:34 PM - Forum: General Help - Replies (1)

Hello,
I have the following problem.. 
I've created a custom 404 page controller and overrided it with routes file. 

But the thing is that in my localhost site this custom 404 page working fine, but in live site, the 404 error page is loaded over "application/views/errors/html/error_404.php" and not from the custom view file with header, footer etc..

Any ideas on what's going on?

Here are routes, controller files etc...

Routes:

Code:
$route['404_override'] = 'c404';

"c404" Controller:
Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class c404 extends MY_Controller {
  public function __construct(){
    parent::__construct();
  }
 public function index(){
   $this->output->set_status_header('404');
   $data['title'] = 'Page not found!';
   $this->render_page('404', $data);
 }

}


My_controller file:
Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Controller extends CI_Controller {
 protected function render_page($view, $data) {
   $data['site'] = $this->page_model->get_info();

   $this->load->view('templates/header', $data);
   $this->load->view($view, $data);
   $this->load->view('templates/footer', $data);
 }

}


Thanks!


  system check the registered email database, and log in to the related DB
Posted by: samuca.ti - 02-19-2019, 10:49 AM - Forum: General Help - Replies (5)

Hello, how do I make the following change in codeigniter, it's possible?

when logging into the system check the registered email database, and log in to the related database, for example:

User: [email protected]
Database: xyz

User: [email protected]
database: abc

after login, this will be the user session database.


I tried in many bad ways it does not work

my function of verification email x database



Code:
function get_base_email($email)
{
   $CI = & get_instance();
   $CI->db->where('email', $email);

   return $CI->db->get('tblusuariobanco')->row()->banco;
}

my database.php


Code:
$db['xyz'] = [
   'dsn'          => '', // Not Supported
   'hostname'     => APP_DB_HOSTNAME,
   'username'     => APP_DB_USERNAME,
   'password'     => APP_DB_PASSWORD,
   'database'     => 'gestor',
   'dbdriver'     => defined('APP_DB_DRIVER') ? APP_DB_DRIVER : 'mysqli',
   'dbprefix'     => '', // Not Supported
   'pconnect'     => false,
   'db_debug'     => (ENVIRONMENT !== 'production'),
   'cache_on'     => false,
   'cachedir'     => '',
   'char_set'     => 'utf8',
   'dbcollat'     => 'utf8_general_ci',
   'swap_pre'     => '',
   'encrypt'      => $db_encrypt,
   'compress'     => false,
   'stricton'     => false,
   'failover'     => [],
   'save_queries' => true,
];

$db['abc'] = [
   'dsn'          => '', // Not Supported
   'hostname'     => APP_DB_HOSTNAME,
   'username'     => APP_DB_USERNAME,
   'password'     => APP_DB_PASSWORD,
   'database'     => 'xxx',
   'dbdriver'     => defined('APP_DB_DRIVER') ? APP_DB_DRIVER : 'mysqli',
   'dbprefix'     => '', // Not Supported
   'pconnect'     => false,
   'db_debug'     => (ENVIRONMENT !== 'production'),
   'cache_on'     => false,
   'cachedir'     => '',
   'char_set'     => 'utf8',
   'dbcollat'     => 'utf8_general_ci',
   'swap_pre'     => '',
   'encrypt'      => $db_encrypt,
   'compress'     => false,
   'stricton'     => false,
   'failover'     => [],
   'save_queries' => true,
];

trying to set the database when signing in

Code:
$active_group = get_base_email($email);



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