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



Search Forums

(Advanced Search)

Forum Statistics
» Members: 19,166
» Latest member: RaisaDus
» Forum threads: 72,029
» Forum posts: 369,352

Full Statistics

Latest Threads
session('something') fail...
Forum: CodeIgniter 4 Support
4 hours ago
» Replies: 0   » Views: 16
Wrong redirection to Conf...
Forum: CodeIgniter 4 Support
4 hours ago
» Replies: 3   » Views: 63
Unable to connect to the ...
Forum: CodeIgniter 4 Support
4 hours ago
» Replies: 10   » Views: 185
find() should be renamed
Forum: CodeIgniter 4 Feature Requests
5 hours ago
» Replies: 3   » Views: 142
Seeder on migration
Forum: CodeIgniter 4 Discussion
5 hours ago
» Replies: 1   » Views: 26
Foreign key on database m...
Forum: CodeIgniter 4 Discussion
6 hours ago
» Replies: 0   » Views: 17
Page is not loading for u...
Forum: General Help
8 hours ago
» Replies: 4   » Views: 177
Encrypter class error
Forum: CodeIgniter 4 Support
9 hours ago
» Replies: 3   » Views: 141
Codeigniter 4 and PHP 8
Forum: CodeIgniter 4 Discussion
9 hours ago
» Replies: 1   » Views: 72
Relations Module
Forum: CodeIgniter 4 Addins
9 hours ago
» Replies: 17   » Views: 3,377

  session('something') fails intemittently
Posted by: 68thorby68 - 4 hours ago - Forum: CodeIgniter 4 Support - No Replies


Part of my project adds an array to the session, which I use on nearly every view in my project.

in my view i access the array

PHP Code:
<?php foreach(session('items') as $arrayKey => $arrayValue) : ?>

                my item: <?= esc($arrayKey?>
                item value: <?= esc($arrayValue?>
             <?php endforeach ?>
Literally, and all of a sudden, every reference to session('item') stops working, in every views, generating (exception s where relevant)

However, if i run print_ in the asscociated controller:
PHP Code:
The session and all of it's content arrays are intact.

As this piece of code is critical to my project it was created some time ago and is never (NEVER) touched.

Is their any reason why session('') would just stop?

Now here's the thing, I thought I maybe somehow be overloaeding the session (adding content / removing content).
So I destroyed the session. - This didnt fix the issue
I closed/restarted the browser - This didnt fix the issue
I restarted the server (hard boot) - This didnt fix the issue

But after all of this, about 2 hours after I first experienced the exceptions, everything all of a sudden works again, and I promise that apart from adding a few print_r here and there, and destroying and restarting sessions I have not changed a thing to my code, CI config or ther server.

Any ideas?????

  Seeder on migration
Posted by: pippuccio76 - 6 hours ago - Forum: CodeIgniter 4 Discussion - Replies (1)

Can i insert multiple row while run migration ? 
For example i have a class PopulateUserState

with a run method :

PHP Code:
        public function run()
                $data = [
                        'stato' => 'Da confermare',
                        'atttivo'    => 1

                // Simple Queries
                $this->db->query("INSERT INTO stato_users (stato, attivo) VALUES(:stato:, :attivo:)",

                // Using Query Builder

Can i launch this method on migration ?

Other answer , how can i add pultiple row on seeder run ?

  Foreign key on database migration
Posted by: pippuccio76 - 6 hours ago - Forum: CodeIgniter 4 Discussion - No Replies

Hi , sorry for english , how can i add a foreign key on migration  ? I cannot find it on users guide

  set_value error on array input field
Posted by: llyimo1920 - 10 hours ago - Forum: CodeIgniter 4 Support - No Replies

<div id="product_content">
<div class="form-group row" id="users_row">
<div class="col">
<input type="text" class="form-control" id="firstname" name="firstname[]" value="<?= set_value('firstname') ?>" placeholder="Enter firstname" required  />
<div class="col">
<input type="text" class="form-control" id="surname" name="surname[]" value="<?= set_value('surname') ?>" placeholder="Enter surname" required  />
<div class="col">
<input type="text" class="form-control" id="yrs_exp" name="yrs_exp[]" value="<?= set_value('yrs_exp') ?>" />
<div class="col">
<input type="text" class="form-control" id="st_salary" name="st_salary[]" value="<?= set_value('st_salary') ?>" />
<div class="col">
<input type="text" class="form-control" id="cr_salary" name="cr_salary[]" value="<?= set_value('cr_salary') ?>" />
<div class="col">
<div class="input-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="passport" name="passport[]" id="passport">
<label class="custom-file-label" for="exampleInputFile">upload image</label>
<div class="col">
<button type="button" class="btn btn-danger" id="btnDelete" disabled>Delete</button>

i'm having difficulties to return validation error to the view form using set_value() function.
In the above sample, i use jquery to clone the above row and submit the form. It works okay if the validations does not find any error, but the problem is that if there is an error, the system responds with an error that set_value() expects string and not array. 
I'm asking for a help if there is a way and if not is there an alternative way to implement array field inputs and display validation errors without losing the field data.

controller function
public function add(){
    helper(['form', 'url']);
    $data = array('page_title' => 'add employees');

    if ($this->request->getMethod() == 'post' && $this->request->isAJAX()) {
        $this->validation = \Config\Services::validation();
        //rules definition i.e. firstname, surname,........
        //errors definition i.e. firstname, surname,........
        //store $_POST field values into arrays $firstname, $surname, ...........
        $rules, $errors;
        for ($i=0; $i < count($fname); $i++) {
            $rules[ 'firstname.' . $i ] = $fname_rules;
            $errors[ 'firstname.' . $i ] = $fname_rules;
        $this->validation->setRules($rules, $errors);
        if ($this->validation->withRequest($this->request)->run()) {
            $files = $this->request->getFileMultiple('passport');
            foreach ($files as $key => $file) {
                if ($file->isValid() && !$file->hasMoved()) {
                    $file->move($this->img_path, $file->getRandomName());
                $img_name[] = $file->getName();
            $emp = array_map(function($item) {
                return array_combine(['firstname', 'surname', .......'image'], $item);
            }, array_map(null, $firstname, $surname, ..........., $img_name));
            //insert into the db using insertbatch()
            return redirect()->to('add');
        else {
            $data['validation'] = $this->validation->getErrors();

    return view('path/to/views', $data);

  How do you insert data into multiple different tables at a time?
Posted by: Polymorphism - 11 hours ago - Forum: General Help - Replies (3)

I am getting my head around CodeIgniter and SQL at the same time and I am currently wondering how do I add data (or indeed, search for data) that is stored in multiple tables?

For example, if I had a 'Users' table and a 'Posts' table, how do I accept that data and store it in the correct tables using CodeIgniter? Also, how would this work for something more complicated that uses more than two tables?

Additionally, how does this apply to selecting data from multiple tables as well?

Id really appreciate some pointers on this.

  Codeigniter 4 and PHP 8
Posted by: ViLar - Today, 01:21 AM - Forum: CodeIgniter 4 Discussion - Replies (1)


As PHP 8 first Beta was released I had the curiosity to check the framework's compatibility with it. To make it short it's pretty cool and good but I stepped on some new errors like `is_callable` function needing an Object instead of a string to work properly or errors being thrown if you declare parameters with default value before parameters without in functions. Of course the entire code was not covered by those small tests. 

Then I wondered if there were any reflexion on the PHP 8 compatibility with Codeigniter 4 and if yes, where could we check and / or contribute to it? If no, do you think we should start building compatibility right now or wait for the stable release by the end of the year?

Here's a reminder of PHP 8 Timetable : https://wiki.php.net/todo/php80

Thanks Smile

  [Turkish] CodeIgniter-3.1.11 send value with uri
Posted by: duke - Yesterday, 12:23 PM - Forum: Regional User Groups - Replies (1)

Bir saat dilimi değiştirme fonksiyonu yazmak istiyorum  , saat dilimini bir hiperlink ile gönderiyorum ve uri ile kontrolördeki değeri çiziyorum.

Aşağıdaki gibi bir köprü ile gönderiyorum

<a href="<?php echo base_url('register/change_timezone/America/New_York');?> "> America / New_York </a>

kayıt / change_timezone / Amerika / New_York

uri ayrıca aşağıdaki gibidir

if ($ this-> uri-> segmenti (3))

ancak bu şekilde gelen değer sadece " Ame rika " dır .

/ Karakterinden sonra başka bir segment olarak değerlendirilir. Bunun gibi / karakterli değerleri 1 segment olarak nasıl gönderebilirim? Php'de saat dilimi olarak çok sayıda / karakter içeren değerler vardır. Bunlar gibi

Amerika / Adak
Amerika / Arjantin / Rio_Gallegos
Amerika / Arjantin / San_ Juan
Amerika / Indiana / Indianapolis

  Wrong redirection to Config/Path in index.php
Posted by: orbitXcover - Yesterday, 10:58 AM - Forum: CodeIgniter 4 Support - Replies (3)

PHP Code:
// Path to the front controller (this file)
// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath FCPATH '../app/Config/Paths.php';
// ^^^ Change this if you move your application folder 
 This is the original code snippet from index.php

Quote:Warning: PHP Startup: failed to open stream: No such file or directory in /index.php on line 31

Warning: PHP Startup: failed to open stream: No such file or directory in /index.php on line 31

Fatal error: PHP Startup: Failed opening required '//../app/Config/Paths.php' (include_path='.:/:/usr/local/php73/lib/pear') in /index.php on line 31

And this is the error displayed

FCPATH = "//"

it gives the wrong address to the file...
Where can I change the constants: __DIR__ and  DIRECTORY_SEPARATOR

Or what is the other solution ??


  Passing data from controller to menu
Posted by: pippuccio76 - Yesterday, 10:29 AM - Forum: CodeIgniter 4 Support - Replies (2)

hisorry for english , if i want pass data from controller to menu can i use this :

PHP Code:
<?= $this->include('templates/head'?>
    <?= $this->include('templates/menu'?>
    <div class="container py-3">
        <?= $this->renderSection('content'?>
<?= $this->include('templates/footer'?>

Or must  i echo the view in controller ?like this:

PHP Code:
echo view('templates/header_client',$data );
echo view('templates/menu_client',$data );

echo view('myViewFolder/myView',$data );

view('templates/footer_client',$data ); 

  gitlab CI/CD pipeline cannot run php spark
Posted by: adty - Yesterday, 03:11 AM - Forum: CodeIgniter 4 Support - Replies (2)

i'm implementing gitlab CI/CD pipeline in my CI4 project.


PHP Code:
php spark migrate 

 in gitlab CI/CD script get this error

CodeIgniter CLI Tool - Version 4.0.4 - Server-Time: 2020-08-11 16:49:30pm

ERROR: 404
Can't find a route for 'cimigrate'.

ERROR: Job failed: exit status 1

I don't get error when execute migration on live server.

is it bug? please help...

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