我有一个带有 mysql 数据库和 laravel 设置的 easyPHP 开发服务器。我已经运行了两次迁移以在数据库中设置两个表,“properties”和“property_images”。
我有两个为属性和property_images 制作的模型。
属性.php:
class Property extends Eloquent {
protected $fillable = array('id','title','type','description');
public function propertyImages() {
return $this->hasMany('PropertyImage');
}
}
属性_image.php:
class Property extends Eloquent {
public function property() {
return $this->belongsTo('Property');
}
}
我正在尝试使用此文件为数据库播种。运行php artisan db:seed
运行文件并输出“已完成的属性表删除”之前的所有内容,然后什么也没有。它永远不会完成命令,就像它卡在一个循环中一样。种子文件:
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$this->command->info('Starting');
$this->call('PropertyTableSeeder');
$this->command->info('Finished first seed');
$this->call('PropertyImageTableSeeder');
$this->command->info('Done seeding');
}
}
class PropertyTableSeeder extends Seeder {
public function run() {
DB::table('properties')->delete();
$this->command->info('Finished Property table delete'); //This line prints out fine
Property::create(array(
'id' => 'caseyTrail1',
'title' => 'Casey Trail 1',
'type' => 'residential',
'description' => 'This is the description for Casey Trail 1.'
));
$this->command->info('Created first property'); //Never reaches this output
Property::create(array(
'id' => 'caseyTrail2',
'title' => 'Casey Trail 2',
'type' => 'residential',
'description' => 'This is the description for Casey Trail 2.'
));
Property::create(array(
'id' => 'castleResidence',
'title' => 'Castle Residence',
'type' => 'residential',
'description' => 'This is the description for Castle Residence.'
));
Property::create(array(
'id' => 'ormandBeach',
'title' => 'Ormand Beach',
'type' => 'residential',
'description' => 'This is the description for Ormand Beach.'
));
Property::create(array(
'id' => 'privateResidence1',
'title' => 'Private Residence 1',
'type' => 'residential',
'description' => 'This is the description for Private Residence 1.'
));
Property::create(array(
'id' => 'assuranceTitle',
'title' => 'Assurance Title',
'type' => 'commercial',
'description' => 'This is the description for Assurance Title.'
));
Property::create(array(
'id' => 'bethesda',
'title' => 'Bethesda',
'type' => 'commercial',
'description' => 'This is the description for Bethesda.'
));
Property::create(array(
'id' => 'choiceBank',
'title' => 'Choice Bank',
'type' => 'commercial',
'description' => 'This is the description for Choice Bank.'
));
Property::create(array(
'id' => 'dawesStreetApartments',
'title' => 'Dawes Street Apartments',
'type' => 'commercial',
'description' => 'This is the description for Dawes Street Apartments.'
));
Property::create(array(
'id' => 'dublins',
'title' => 'Dublins',
'type' => 'commercial',
'description' => 'This is the description for Dublins.'
));
Property::create(array(
'id' => 'langFinancial',
'title' => 'Lang Financial',
'type' => 'commercial',
'description' => 'This is the description for Lang FInancial.'
));
Property::create(array(
'id' => 'skiersOutlet',
'title' => 'Skiers Outlet',
'type' => 'commercial',
'description' => 'This is the description for Skiers Outlet.'
));
$this->command->info('Finished Property run');
}
}
class PropertyImageTableSeeder extends Seeder {
public function run() {
DB::table('property_images')->delete();
PropertyImage::create(array(
'property_id' => 'caseyTrail1',
'filename' => 'picture1',
'title' => 'Casey Trail 1 Picture 1'
));
PropertyImage::create(array(
'property_id' => 'caseyTrail1',
'filename' => 'picture2',
'title' => 'Casey Trail 1 Picture 2'
));
PropertyImage::create(array(
'property_id' => 'caseyTrail1',
'filename' => 'picture3',
'title' => 'Casey Trail 1 Picture 3'
));
PropertyImage::create(array(
'property_id' => 'caseyTrail2',
'filename' => 'picture1',
'title' => 'Casey Trail 2 Picture 1'
));
PropertyImage::create(array(
'property_id' => 'caseyTrail2',
'filename' => 'picture2',
'title' => 'Casey Trail 2 Picture 2'
));
PropertyImage::create(array(
'property_id' => 'caseyTrail2',
'filename' => 'picture3',
'title' => 'Casey Trail 2 Picture 3'
));
}
}
当我让命令运行一段时间时,它最终给出了这个错误输出:
D:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localweb\projects\cwa>php
artisan db:seed
Failed loading D:\PROGRA~2\EASYPH~1.1VC\binaries\php\php_runningversion\php_xdeb
ug-2.2.2-5.4-vc9.dll
Starting
Finished Property table delete
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to all
ocate 32 bytes) in D:\Program Files (x86)\EasyPHP-DevServer-13.1VC11\data\localw
eb\projects\cwa\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.
php on line 615