Welcome Guest, Not a member yet? Register   Sign In
[CI4][seeder] Clarify or fix a confused point in the Seeder class

(This post was last modified: 02-07-2023, 11:54 AM by Pasc.)

Code Igniter 4.3.1
In class vendor/codeigniter4/framework/system/Database/Seeder.php we have : 

PHP Code:
    public function __construct(Database $config, ?BaseConnection $db null)
        $this->seedPath $config->filesPath ?? APPPATH 'Database/';

        if (empty($this->seedPath)) {
            throw new InvalidArgumentException('Invalid filesPath set in the Config\Database.');

        $this->seedPath rtrim($this->seedPath'\\/') . '/Seeds/';

        if (! is_dir($this->seedPath)) {
            throw new InvalidArgumentException('Unable to locate the seeds directory. Please check Config\Database::filesPath');

        $this->config = &$config;

        $db ??= Database::connect($this->DBGroup);

        $this->db    $db;
        $this->forge Database::forge($this->DBGroup);
The line (94 in the code) is not correct :  
PHP Code:
$db ??= Database::connect($this->DBGroup); 
The fusion null operator (??) is suffixed with an equal sign  (=). The connection should be instantiated there only if $db is null by $DBGroup, which does not work!
It sould be written:
PHP Code:
$db ?? Database::connect($this->DBGroup); 

What do you mean?
Why does not it work? What's happened?

Theme © iAndrew 2016 - Forum software by © MyBB