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



Search Forums

(Advanced Search)

Forum Statistics
» Members: 24,629
» Latest member: situstototogelterpercaya
» Forum threads: 73,483
» Forum posts: 375,927

Full Statistics

Latest Threads
ci_session cookie rejecti...
Forum: CodeIgniter 4 Support
17 minutes ago
» Replies: 8   » Views: 3,498
Databases: searching for ...
Forum: General Help
31 minutes ago
» Replies: 11   » Views: 341
Class not found
Forum: General Help
51 minutes ago
» Replies: 1   » Views: 41
CodeIgniter v4.1.2 releas...
Forum: News & Discussion
9 hours ago
» Replies: 11   » Views: 453
Forum: CodeIgniter 4 Support
10 hours ago
» Replies: 1   » Views: 51
get and post filtering fo...
Forum: CodeIgniter 4 Discussion
Today, 08:50 AM
» Replies: 5   » Views: 128
Swith to object oriented ...
Forum: General Help
Today, 08:45 AM
» Replies: 10   » Views: 585
The requested URL was not...
Forum: Addins
Today, 07:53 AM
» Replies: 0   » Views: 43
No sessions in testing en...
Forum: CodeIgniter 4 Support
Today, 07:26 AM
» Replies: 3   » Views: 41
Looking for CI developer ...
Forum: Jobs
Today, 07:25 AM
» Replies: 2   » Views: 91

  Swith to object oriented programming
Posted by: blab99778 - 05-05-2021, 10:53 AM - Forum: General Help - Replies (10)

Hi! I have used CodeIgniter 3 to develop my first web app. I learnt programming (including object oriented programming) years ago but never used in a real application. I have already finished my first working web app but I think I didn't use OOP. I don't make myself clear with how to use it, so I will try to post a short summary of what I have programmed (only what is necessary to understand my approach) and, please, I would like to know how it should look in OOP, if it is worth doing that change to make it easier to add functionality in the future..


PHP Code:
class Customer_model extends CI_Model
    public function __construct()

    public function getCustomers()
$result $this->db->get('customers')->result();

    public function getCustomer($id_customer)
//database sql
$customer $query->row();        
        return $customer;

    public function getInvoices($id_customer)
        //database sql
        $query $this->db->get();
        return $query->result();

PHP Code:
class Customers extends CI_Controller {
public function __construct()
        Show all customers. From this page the detail of one customer can be accessed (calling to the next function)
public function index()
$data['customers'] = $this->gestion_model->getCustomers();
        Show one customer with his/her invoices
public function customer($id_customer)
$data['customer'] = $this->gestion_model->getCustomer($id_customer);
$data['invoices'] = $this->gestion_model->getInvoices($id_customer);

The customer/all view:
PHP Code:
<?php foreach($customers as $customer): ?>
    <td><?php echo $customer->id?></td>
    <td><?php echo $customer->name?></td>

And the customer/detail view:
PHP Code:
<?php echo $customer->id?></td>
<?php echo $customer->name?></td>
<?php foreach($invoices as $invoice): ?>
    <td><?php echo $invoice->date?></td> 

The full views and other functions in model and controller (to insert and update data) are not required to undertand how I managed to organize my app.

So, my general question is how to do this app OOP because I understand what I did is not OOP, as I haven't created a "customer" or "invoice" classes. And the particular questions are:
  • Should I define Customer_model as a class representing a customer (with attributes like id, name...), so the class representes ONE customer, or it should represent ALL customers? So, how should I rewrite getCustomers() and getCustomer($id_customer)?
  • Any changes to the controller?
  • Any changes to the views?
Thanks and sorry if this is a very general question, but I really like CodeIgniter and want to fully understand how things should work.

  Trouble with view_cell
Posted by: Zeff - 05-05-2021, 07:25 AM - Forum: CodeIgniter 4 Support - Replies (2)

Hi folks,
I tried to use the view_cell() function in a view file, but I always get an error: 


Return value of CodeIgniter\View\Cell::render() must be of the type string, null returned
My view file is very simple, I just inserted a view_cell() in the default CI welcome_message.php:
<div class="heroe">
    <h1>Welcome to CodeIgniter <?= CodeIgniter\CodeIgniter::CI_VERSION ?></h1>
    <h2>The small framework with powerful features</h2>

<!-- CONTENT -->


    <h1>About this page</h1>

The TestController.php (which has no constructor!) has a simple method:

public function bar()
    echo 'BAR';
I use no params, so it's a very simple test but I keep on getting this error!

Many thanks for the golden tip! [Image: wink.png]

Attached Files Thumbnail(s)

  How to attach a file without the user being able to explore all files?
Posted by: christaliise - 05-05-2021, 06:43 AM - Forum: General Help - Replies (15)

We have a series of files that are categories & have a system where a user can create an advert, but the only way we can see to attach an advert into the category is by using HTML input type="file" however that gives the user access to all the folders & files in the computer where we would prefer to limit the users access to only files in Adverts folder & under his/her username. We have tried a few snippets of HTML coding to try such limitation but nothing has worked.

Even if we could get some HTML coding to work we do realize that HTML is frontend, similar to Javascript, & suspect that a clever user could manipulate the HTML coding stored in "his/her own browser" & gain access to whatever is desired. We dont want that.

Is there any PHP backend coding that will restrict a user to say the Adverts folder & under his/her username?

  New XAMPP Releases
Posted by: InsiteFX - 05-05-2021, 05:04 AM - Forum: Lounge - Replies (3)

XAMPP 7.4.18 and XAMPP 8.0.5 Released.

  Route call wrong method
Posted by: sfarzoso - 05-03-2021, 10:37 AM - Forum: CodeIgniter 4 Support - Replies (7)

I have this routes:

PHP Code:
$routes->group('admin', function ($routes) {

$routes->group('media', [
'filter'         => 'permission:manage-media',
'namespace'        => 'App\Controllers',
'controller'    => 'Media',
'except'        => 'show'
], function ($routes) {




this is what CI returns:

[Image: YtUQs06.png]

now if I call a delete method for admin/media/1 all works as expected, but when I call admin/media/directory/1


PHP Code:
    url: `<?= route_to('admin/media/directory') ?>/1`,
done((datatextStatusjqXHR) => {
fail((error) => {

this will call the method delete() of the Media controller instead of call the method directory, why?

  Cannot execute query update with multiple rows
Posted by: sfarzoso - 05-03-2021, 08:13 AM - Forum: CodeIgniter 4 Support - Replies (1)

I'm trying to update multiple rows using this code:

PHP Code:
$directoryId $this->request->getPostGet('directory_id');
        $where $this->request->getPostGet('media_ids');
        $result $this->post->whereIn('id'$where)->update('parent'$directoryId); 

essentially $where contains this:

PHP Code:
array(2) {

and $directoryId is: 1132

I get:

PHP Code:
Return value must be of type array, string returned 

  trying to require
Posted by: richb201 - 05-03-2021, 04:19 AM - Forum: General Help - Replies (7)

I am trying to use the sendpulse library.  First I tried to load it with Composer but composer complains that I should be using Composer2. When I try to upgrade to Composer2 that fails. So then I tried to manually load. 

I tried

require APPPATH."../vendor/sendpulse-rest-api-php-master/src/Storage/ApiInterface.php";

I am getting this error:
Severity: Warning
Message: require(/app/application/../vendor/sendpulse-rest-api-php-master/src/Storage/ApiInterface.php): failed to open stream: No such file or directory

then I tried:

require "/vendor/sendpulse-rest-api-php-master/src/Storage/ApiInterface.php";
but I get the following:
Message: require(/vendor/sendpulse-rest-api-php-master/src/Storage/ApiInterface.php): failed to open stream: No such file or directory

and then I tried:

require ("sendpulse-rest-api-php-master/src/Storage/ApiInterface.php");

But I get
Message: require(sendpulse-rest-api-php-master/src/Storage/ApiInterface.php): failed to open stream: No such file or directory

I then changed the owner with chown and the permissions with chmod. Now when I ls -l I get:

[email protected]:/opt/docker-substantiator2/app/vendor/sendpulse-rest-api-php-master/src$ ls -l ApiInterface.php

-rwxrwxrwx 1 richb201 richb201 10828 Dec 15 10:25 ApiInterface.php

But I still get:
A PHP Error was encountered

Severity: Compile Error

Message: require(): Failed opening required 'sendpulse-rest-api-php-master/src/Storage/ApiInterface.php' (include_path='.:/opt/bitnami/php/lib/php')
Filename: controllers/Users_start_login.php

Can anyone tell me what is wrong?

Question Multicountry and multilanguage website
Posted by: endriu - 05-03-2021, 12:44 AM - Forum: General Help - Replies (2)

Hi everyone!

I need to develop a multicountry website in which each country can have 1 to 3 languages.
The structure I would like to obtain looks like this:

United States:



So the URL will consist of: domain/country/language

Furthermore, I will need to be able to customize content based on the selected country.

Could you recommend me a method/tutorial to follow?

Thank you!

  Call to a member function on bool
Posted by: mauroMbs - 05-02-2021, 01:41 PM - Forum: CodeIgniter 4 Support - Replies (2)

I'm stuck on validation.
the "validate" instance does not recognize the "hasError" functions:
returning the error:
Call to a member function hasError () on bool

PHP Code:
$validation $this->validate([
'user'    =>'required',
//            'mail'    =>'required|valid_email|is_unique[users.mail]',
'mail'    =>'required|valid_email',
'pswd'     =>'required|min_length[5]|max_length[12]',
'cPswd'    =>'required|min_length[5]|max_length[12]|matches[password]'

$usrErr $validation->hasError('user') ? $validation->getError('user') : "";
'user: '.$usrErr;                


after seeing and reviewing several tutorials on the subject, I am at a standstill.

I hope to get help from the experts

  Codeigniter 4 IonAuth 4 get logged in user
Posted by: underware - 05-02-2021, 12:04 PM - Forum: CodeIgniter 4 Discussion - Replies (2)

Managed to add ionAuth. How do I get logged in user in views?

PHP Code:

namespace App\Controllers;

Home extends BaseController
    public function 
        if (!$this->ionAuth->loggedIn()) {
            // redirect them to the login page
            return redirect()->to('/auth/login');
        } else {

PHP Code:

namespace App\Controllers;


BaseController extends Controller

$helpers = [];

    public function 
initController(RequestInterface $requestResponseInterface $responseLoggerInterface $logger)
// Do Not Edit This Line
$this->ionAuth = new \IonAuth\Libraries\IonAuth();

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