Open vipers-web-design opened 1 year ago
I got Composer set up and working, I'm still getting the one error. Now I'm linking through the autoload script.
Exception Object
(
[message:protected] => Something unexpected happened: some tables possibly cannot be filled
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /Users/andrewford/Creative Cloud Files/VWD-Active-Portfolio/feedverse.net/vendor/tebazil/db-seeder/src/Seeder.php
[line:protected] => 46
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /Users/andrewford/Creative Cloud Files/VWD-Active-Portfolio/feedverse.net/faker.php
[line] => 161
[function] => refill
[class] => tebazil\dbseeder\Seeder
[type] => ->
[args] => Array
(
)
)
)
[previous:Exception:private] =>
)
I found the cause, I'm trying to pass a relation id
into a column. The data is already in my database from the countries
table from this repo https://github.com/dr5hn/countries-states-cities-database.
$seeder = new \tebazil\dbseeder\Seeder($pdo);
$generator = $seeder->getGeneratorConfigurator();
$faker = $generator->getFakerConfigurator();
$seeder->table('users')->columns([
'userid' => $generator->pk,
'country' => $generator->relation('countries', 'id')
])->rowQuantity(100);
I'm getting the extra errors;
Notice: Undefined index: countries in /Users/andrewford/Creative Cloud Files/VWD-Active-Portfolio/feedverse.net/vendor/tebazil/db-seeder/src/Seeder.php on line 69
Warning: in_array() expects parameter 2 to be array, null given in /Users/andrewford/Creative Cloud Files/VWD-Active-Portfolio/feedverse.net/vendor/tebazil/db-seeder/src/Seeder.php on line 69
So a workaround is using an anonymous function to get a random number between x & y based on how many rows exist in that table;
'country' => function() {
return rand(1, 250);
}
What minimum version of PHP is supported?
And how about having this work for people to don't use Composer? Old fashion, manual installation. Is there a correct order?
I'm getting the error;
At first, I was going to focus on 4 tables but was getting the error above. Then I thought focusing on one table at a time would be okay, except I'm still getting the error.
On line 45 of Seeder.php, I manually added space between the operator
if($foolProofCounter++ > 500)
in case if my parser was having a hard time reading the++>
.I'm following this tutorial; https://smarttutorials.net/seedpopulate-mysql-database-dummytest-data-using-php-db-seeder/