(07-18-2020, 06:03 AM)MGatner Wrote: Welcome to PHP and CodeIgniter! Glad you found Myth:Auth - I think it’s a great module.
Helpers are a set of function definitions, not really anything more. In order to use any of those functions you need to load their definitions, and adding the list to the controller is a great way to do it. logged_in() is a function provided by Myth:Auth’s auth_helper
I'm a little embarrassed of asking another Myth::Auth related question, since a am a newbie in this forum. But i ran into another problem.
I started a little project at work, where i am forced to use a Windows 10 client.
Now i wanted to continue on this project at home, where i use Manjaro Linux.
I just downloaded my project folder and correctly configured my .env file, according to my database (i am using a fresh intsall of XAMPP).
But when in try to run my migrations, using the following command:
Code:
php spark migrate -all
I'll get the following exceptions:
Code:
CodeIgniter CLI Tool - Version 4.0.4 - Server-Time: 2020-07-20 06:16:02am
Running all new migrations...
An uncaught Exception was encountered
Type: CodeIgniter\Database\Exceptions\DatabaseException
Message: Unable to connect to the database.
Filename: /opt/lampp/htdocs/stundenplanTest2/vendor/codeigniter4/framework/system/Database/BaseConnection.php
Line Number: 425
Backtrace:
-109 - /opt/lampp/htdocs/stundenplanTest2/vendor/codeigniter4/framework/system/Database/Database.php::initialize
-148 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/Database/Config.php::loadForge
-78 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/Database/Migration.php::forge
-1026 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/Database/MigrationRunner.php::__construct
-223 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/Database/MigrationRunner.php::migrate
-128 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/Commands/Database/Migrate.php::latest
-100 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/CLI/Commands.php::run
-107 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/CLI/CommandRunner.php::run
-85 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/CLI/CommandRunner.php::index
-914 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/CodeIgniter.php::_remap
-404 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/CodeIgniter.php::runController
-312 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/CodeIgniter.php::handleRequest
-86 - /opt/lampp/htdocs/Test2/vendor/codeigniter4/framework/system/CLI/Console.php::run
-57 - /opt/lampp/htdocs/Test2/spark::run
But the tables are there afterwards.
The second problem is related to the database-seeder.
When i try to run:
Code:
php spark db:seed GroupSeeder
It results in:
Code:
CodeIgniter CLI Tool - Version 4.0.4 - Server-Time: 2020-07-20 06:17:05am
Unknown column 'name' in 'field list'
/opt/lampp/htdocs/stundenplanTest2/vendor/codeigniter4/framework/system/Database/MySQLi/Connection.php - 331
Here is the Seeder:
<?php
namespace App\Database\Seeds;
class GroupSeeder extends \CodeIgniter\Database\Seeder
{
public function run()
{
$data = [
'name' => 'admins',
'description' => 'godlike'
];
// Simple Queries
$this->db->query("INSERT INTO auth_groups (name, description) VALUES(:name:, :description:)",
$data
);
// Using Query Builder
$this->db->table('users')->insert($data);
Code:
But again, the entry is there afterwards, but the seeder is only working, making one entry, but the seeder originally was intended to create more groups an worked just fine at work.