Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14343 articles
Browse latest View live

Is future CI will implement HMVC by default/without 3rd party?

$
0
0
I searched this topic in github, this forum and google. But i still didnt get exact reason why CI still not (will not) implement HMVC.

Anyone can give me the reason?

I will appreciate any reply. thanks.

Note: I still using HMVC extension since 4 years ago.

Advance Tutorials

$
0
0
Can we expect any paid advance codeigniter 4 tutorials videos or book around ci4 release dates ?

Issues accessing CI forums

$
0
0
I have no problem accessing the CI forums at home but when I work for clients at their secured work environments I have trouble accessing the website and forums.  I receive this error:
Host: codeigniter.com

Reason: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error


I was just wondering if anyone else was experiencing this issue.  
...And yes, I did look it up...and no, the clients are not planning to make changes on their end.

Model for the login, anybody help me

$
0
0
I am trying to learn codeigniter.

I have manage to make it work but I would like to ask how would I include a model to validate the username and password in the DB and get the details.

Thanks.

Different timezone between browser

$
0
0
Hi!

Chrome and Firefox the session stays as greenwich time, it's not the timezone of CI4 and PHP. But in the session in Safari is correct.

CI4:
public $appTimezone = 'America/Sao_Paulo';

php.ini:
date.timezone = America/Sao_Paulo

Removed Model and Controller but erroring

$
0
0
Hello, I removed both the model and the controller to clean up my files.     
Now I get "Message: Unable to locate the model you have specified: MyModle_name" .   
Full Error:
    
An uncaught Exception was encountered
Type: RuntimeException

Message: Unable to locate the model you have specified: MyModle_name

Filename: /var/www/html/myfolder/system/core/Loader.php

Line Number: 347

Backtrace:

File: /var/www/html/myfolder/application/controllers/Test.php
Line: 23
Function: __construct

File: /var/www/html/myfolder/index.php
Line: 315
Function: require_once

What could be causing this?

Traffic Tracking Library

$
0
0
Hi all! I'm a long-time user with many live CI3 projects. Managing libraries across them got to be almost as much work as each project, so I developed five "zero conf" libraries to add core functions I needed which could be dropped in and used without setup. I never got around to publishing them, but as I rewrite them for CI4 I'll be making them available.
Next up, the third library:

Tatter/Visits - "Zero conf" traffic tracking for CodeIgniter 4

Basic usage:
1. Install with Composer: `> composer require tatter/visits`
2. Update the database: `> php spark migrate:latest -n Tatter`
3. Add to controller: `service('visits')->record();`


I learned a lot from this library as it is more involved than the previous two, so I'll be reworking the Asset Loader and User Alert libraries to be more "CodeIgniter 4"-style. As always I am eager for feedback, suggestions, and contributions - feel free to respond here or on GitHub (https://github.com/tattersoftware/codeigniter4-visits).
Thanks for reading!

Any way to use the query builder without a database connection?

$
0
0
Hi All -


I'm hoping to use the CI query builder (we're in v3) to generate SQL statements. The only problem is that we don't actually have a connection to run them in. Our application sends queries via a web service to have them run against a cloud-hosted MySQL instance (passing the select statement as the HTTP body).

Is there any way to use CI's query builder to simply generate the SQL statement and to return the assembled statements as strings?

Thanks in advance -

Trent

csrf_exclude_uris not work

$
0
0
$config['csrf_protection'] = true;
$config['csrf_token_name'] = 'csrf_token_test';
$config['csrf_cookie_name'] = 'csrf_cookie_test';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array('/assistant_dashboard/upload.html');
Confused
I upload file to '/assistant_dashboard/upload.html' but the 'csrf_exclude_uris' not work.
Please show me how to do?

CI 3 and community auth

$
0
0
Hello,  I'm new to CI and Community Auth.  I've followed a tut I found on YouTube and it's working so far.  I was wondering if someone could give an assist on a registration feature to community auth.  So far I can see you can add users in the code ... but I was thinking of a view with a form to register.  I'm still getting my head wrapped around this MVC stuff so any assist would be greatly appreciated!

X

pass variables to boostrap model

$
0
0
hi,
i want to get this output as in the attachment.


how to change this code to get output like this?
Code:
function payroll_detail(id)
  {
    $('#form_payroll_detail')[0].reset(); // reset form on modals
    $('.form-group').removeClass('has-error'); // clear error class
    $('.help-block').empty(); // clear error string
   
      show_loading();
      //Ajax Load data from ajax
    $.ajax({
      url : "<?php echo site_url('index.php/User/get_payroll_detail/')?>/" + id,
      type: "GET",
      dataType: "JSON",
      success: function(data)
      {
          $('[name="id"]').val(data.id);          
          $('[name="emp_no"]').val(emp_no);
          $('[name="name"]').val(name );
          $('[name="basic_salary"]').val(basic_salary );
          $('[name="gross_salary"]').val(gross_salary );
            $('[name="net_salary"]').val(net_salary );
           $('[name="epf"]').val(epf );
           $('[name="etf"]').val(etf);

          $('#modal_form_payroll_detail').modal('show'); // show bootstrap modal when complete loaded
          $('.modal-title').text('Payroll Detail'); // Set title to Bootstrap modal title
              hide_loading();
      },
      error: function (jqXHR, textStatus, errorThrown)
      {
          alert('Error get data from ajax');
      }
  });
  }


///model///
Code:
//////////payroll_detail///
     public function get_payroll_detail($id){

        $this->load->model('Model_user');
        $data = $this->Model_user->get_payroll_detail_by_id($id);
        echo json_encode($data);
    }



////controller//
Code:
public function get_payroll_detail_by_id($id){

                $this->db->from('payroll_detail');
                $this->db->where('payroll_head_id',$id);
                $query = $this->db->get();
               //echo '<pre>', print_r($query->result(), true), '</pre>';
                return $query->result();             
    }


.png   payrl.png (Size: 22.73 KB / Downloads: 0)

pass variables to boostrap model

$
0
0
hi,
i want to get this output as in the attachment.


how to change this code to get output like this?

Code:
function payroll_detail(id)
 {
   $('#form_payroll_detail')[0].reset(); // reset form on modals
   $('.form-group').removeClass('has-error'); // clear error class
   $('.help-block').empty(); // clear error string
 
     show_loading();
     //Ajax Load data from ajax
   $.ajax({
     url : "<?php echo site_url('index.php/User/get_payroll_detail/')?>/" + id,
     type: "GET",
     dataType: "JSON",
     success: function(data)
     {
         $('[name="id"]').val(data.id);          
         $('[name="emp_no"]').val(emp_no);
         $('[name="name"]').val(name );
         $('[name="basic_salary"]').val(basic_salary );
         $('[name="gross_salary"]').val(gross_salary );
           $('[name="net_salary"]').val(net_salary );
          $('[name="epf"]').val(epf );
          $('[name="etf"]').val(etf);

         $('#modal_form_payroll_detail').modal('show'); // show bootstrap modal when complete loaded
         $('.modal-title').text('Payroll Detail'); // Set title to Bootstrap modal title
             hide_loading();
     },
     error: function (jqXHR, textStatus, errorThrown)
     {
         alert('Error get data from ajax');
     }
 });
 }
///model///
Code:
//////////payroll_detail///
     public function get_payroll_detail($id){

        $this->load->model('Model_user');
        $data = $this->Model_user->get_payroll_detail_by_id($id);
        echo json_encode($data);
    }


///controller///
Code:
public function get_payroll_detail_by_id($id){

                $this->db->from('payroll_detail');
                $this->db->where('payroll_head_id',$id);
                $query = $this->db->get();
               //echo '<pre>', print_r($query->result(), true), '</pre>';
                return $query->result();            
    }


.png   payrl.png (Size: 22.73 KB / Downloads: 0)

CI4 Beta 1: function _remap not works properly

$
0
0
my english is not the best.

in Codeigniter 3 I do:

URL:
/test/parameter1/parameter2/<parameterN>

CI3
called class: Test 
called method:  _remap (I have it function declared).

in Codeigniter 3 all works ok.

but in Codeigniter 4,

with URL:
/test
CI4 call method _remap, woks ok.

but with URL:
/test/parameter1
or URL 
/test/parameter1/parameter2/<parameterN>

show error: ReflectionException "Method App\Controllers\Test::parameter1() does not exist"

-----

Details:
- No setting route additional.
- I try wihtout function index, but it does not affect.

PHP Code:
<?php namespace App\Controllers;

use 
CodeIgniter\Controller;

class 
Test extends Controller
{
    public function 
index()
    {
        echo 
"Test/index";
    }
    
//--------------------------------------------------------------------
    
public function _remap($method)
    {
        echo 
"Test/remap - {$method}";
    }
    
//--------------------------------------------------------------------




excuse my english, I appreciate the help. thanks!!

.png   ci4-error.png (Size: 68.45 KB / Downloads: 1)

Problem with the uploaded image in the upload folder

$
0
0
I am making an update function for my profile page that includes user data and profile picture. The update function is working and the profile picture can be updated but the problem is I don't know what did I do until the update function uploaded 99 same picture in my upload folder. I follow this tutorial on this page https://www.susantokun.com/cara-update-p...deigniter/. I am still new in CodeIgniter. Can someone help me with this?  Huh 

this is controller user.php for calling the edit page : 

Code:
    public function edit(){
    
    $data['userInfo'] = $this->user_model->fetchUserData($this->session->userdata('user_id'));


    $data['title'] = 'Update Profile';

    // Check login
            if(!$this->session->userdata('logged_in')){
                redirect('users/login');
            }


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

controller user.php for update function : 

Code:
    //update profile
    public function updateprofile(){

        // Check login
            if(!$this->session->userdata('logged_in')){
                redirect('users/login');
            }


        $this->form_validation->set_rules('tel', 'Telephone', 'required');

      $id = $this->session->userdata('user_id');

        $data = array(
                    'name' => $this->input->post('name'),
                    'address' => $this->input->post('address'),
                    'website' => $this->input->post('website'),
                    'tel' => $this->input->post('tel'),
                    'fax' => $this->input->post('fax')
                    );

  if ($this->form_validation->run() == true) {

    if (!empty($_FILES['avatar']['name'])){
        $upload = $this->_do_upload('userfile');

      //delete file
   $user = $this->user_model->get_by_id($this->session->userdata('user_id'));

           $data['avatar'] = $upload;
          }

  $result = $this->user_model->update($data, $id);

            if ($result > 0) {
               $this->updateprofile();
               // set message
            $this->session->set_flashdata('update_profile','Your Profile have been updated');
               redirect('users/edit');
           } else {
               $this->session->set_flashdata('failedupdate_profile','Failed to update');
               redirect('users/edit');
           }
     
   }
}

 
controller user.php for the  _do_upload() function : 

Code:
 private function _do_upload()
   {
       $config['upload_path']          = './assets/upload';
       $config['allowed_types']        = 'gif|jpg|jpeg|png';
       $config['max_size']             = 2048; //set max size allowed in Kilobyte
       $config['max_width']            = 2000; // set max width image allowed
       $config['max_height']           = 2000; // set max height allowed
       
       $this->load->library('upload', $config);

       if (!$this->upload->do_upload('avatar')) {

           $this->session->set_flashdata('msg', $this->upload->display_errors('', ''));
           redirect('users/edit');
       }
       return $this->upload->data('file_name');
   }

this is my model : user_model.php 

Code:
public function update($data, $id)
   {
       $this->db->where('user_id', $id);
       $this->db->update('omg_user', $data);
       return $this->db->affected_rows();
   }

 public function get_by_id($id)
   {
       $this->db->select('*
           ');

       $this->db->from('omg_user');
       $this->db->where('user_id');
       $query = $this->db->get();
       return $query->row();
   }

the view for edit page : 

Code:
<!-- sign up start -->
<?php echo validation_errors(); ?>

<div class="container">
 <!-- Flash messages -->
 <?php if($this->session->flashdata('update_profile')): ?>
   <?php echo '<p class="alert alert-success">'.$this->session->flashdata('update_profile').'</p>'; ?>
 <?php endif; ?>
</div>

<div class="container">
 <!-- Flash messages -->
 <br><br>
 <?php if($this->session->flashdata('failedupdate_profile')): ?>
   <?php echo '<p class="alert alert-danger">'.$this->session->flashdata('failedupdate_profile').'</p>'; ?>
 <?php endif; ?>
</div>

<?php echo form_open_multipart('users/updateprofile'); ?>

   <section class="blog single-blog section">
   <div class="container">

       <div class="row">
           <div class="col-md-4 offset-md-4">
               <div class="widget dashboard-container my-adslist">
<h1 class="text-center"><?= $title; ?></h1><br><br>
  <input type="hidden" name="id" id="id" value="<?php print $userInfo['user_id'] ?>" />

   <div class="form-group">
       <label> Username :  </label>
       <span style="color: orange"><?php print $userInfo['username']; ?></span>
     
   </div>
   <div class="form-group">
       <label> Your Name </label>
       <input type="text" class="form-control" name="name" value="<?php print $userInfo['name']; ?>">
   </div>
   <div class="form-group">
       <label> Picture </label>
       <div class="fileupload-new thumbnail">
       <img src="<?php echo base_url();?>assets/upload/<?php echo $userInfo['avatar']?>" class="fileupload-new thumbnail" style="width: 100px; height: 100px;float: left;margin-right: 10px;"/>
   </div>
       <input type="file" class="form-control" name="avatar" value="<?php print $userInfo['avatar']; ?>">
   </div>
   <div class="form-group">
       <label> Address </label>
       <input type="text" class="form-control" name="address" value="<?php print $userInfo['address']; ?>">
   </div>
   <div class="form-group">
       <label> Fax </label>
       <input type="text" class="form-control" name="fax" value="<?php print $userInfo['fax']; ?>">
   </div>
   <div class="form-group">
       <label> Telephone </label>
       <input type="text" class="form-control" name="tel" value="<?php print $userInfo['tel']; ?>">
   </div>
   <div class="form-group">
       <label> Website </label>
       <input type="text" class="form-control" name="website" value="<?php print $userInfo['website']; ?>">
   </div>
   
<input type="submit" name="submit"class="btn btn-default" value="Update">

</div>
</div>
</div>
</div>
</section>

<?php echo form_close(); ?>
<!-- Sign up end -->

Controller in subfolder

$
0
0
Hello all, I'm studying how to separate my project so that my Controllers don't get too big, with many methods and parameters in each method, wich could cause a tremendous headache in future development. For doing so I wish to create subfolders inside the /app/Controller folder, and save my Controllers there, but I'm having trouble defining the Route for them, here is what I've tryied:

$routes->add('configuracoes/callcenter', 'Configuracoes/Callcenter::index');
or
$routes->add('configuracoes/callcenter', 'Configuracoes\Callcenter::index');
or
$routes->add('configuracoes/callcenter', 'App\Controllers\Configuracoes\Callcenter::index');

But all I get is:
"Controller or its method is not found: \App\Controllers\Configuracoes\Callcenter::index"

My folder structure is just like this:
App
-Config
-Controllers
--Configuracao
---Callcenter.php
etc...

Any tips?

ERROR LINK mysite

Unable to load the requested language file: language/english/_lang.php

$
0
0
I was trying to implement language support in Codeigniter. It was working until some change that I'm unable to detect, makes any controller throw this error.
I'm not trying to load any language file in particular. I suspect that Codeigniter is trying to load an empty $langfile variable from load() function in system/core/Lang.php.

Documentation ? and Requests

$
0
0
From https://www.codeigniter.com/user_guide/i...e_300.html

This not clear to me.  it says rename active_record ; but shows, active_group and a query_builder variable? 

Suggest edit[a) you need to add the following (if not there)
or
b)You need to change the following
or
3) This is what it looks like

Step 7: Update your config/database.php


Due to 3.0.0’s renaming of Active Record to Query Builder, inside your config/database.php, you will need to rename the 
Code:
$active_record

 variable to 

Code:
$query_builder

:

$active_group = 'default';
// $active_record = TRUE;
$query_builder = TRUE;

How to make a PDF file of the user guide?

$
0
0
Running make latexpdf results in the error message
Quote:make: latexmk: No such file or directory


Running make latex seems to work and produces CodeIgniter.tex. But running pdftex on CodeIgniter.tex fails.

PS: Can I download a PDF file of the user guide anywhere?

how codeigniter join two tables to have both Id columns

$
0
0
I want to join two tables that I have both Id columns in join table by codeigniter. I want both id column from comment and users tables.
I write below code

Code:
$this->db->select('users.name as user_full_name, users.id as userid', false);
   $this->db->from('users');

   $this->db->select()
       ->from('comment')
       ->where('project_id', $projectId)
       ->where('user_id', $user_id)
       ->join('users', 'comment.user_id_from =userid')
       ->order_by("comment.id", "asc");
   return $this->db->get()->result_array();

but face error, I do not know why

error:

Code:
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM (users, comment) JOIN users ON comment.user_id_from =userid W' at line 1

SELECT users.name as user_full_name, users.id as userid, * FROM (users, comment) JOIN users ON comment.user_id_from =userid WHERE project_id = '3' AND user_id = '84' ORDER BY comment.id ASC

please show me how to solve it
Viewing all 14343 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>