コード例 #1
0
ファイル: item.docs.php プロジェクト: laiello/php-garden
/** 1.5. Create two new materials */
$mat_1 = new Material();
$mat_1->belongs_to($company);
$mat_1->name = 'Skóra';
$mat_1->save();
$mat_2 = new Material();
$mat_2->belongs_to($company);
$mat_2->name = 'Drewno brzozowe';
$mat_2->save();
/** 1.6. Check if materials successfully created */
debug($mat_1->load());
debug($mat_2->load());
/** 1.7. Create a new material combination */
$comb = new Combination();
$comb->belongs_to($product);
$comb->has_multiple($mat_1, $mat_2);
$comb->price = '12.34';
$comb->save();
/** 1.8. Check if combination successfully created */
debug($comb->load());
/*
CREATE TABLE `product` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `company_id` int(10) unsigned NOT NULL,
  `name` text collate utf8_polish_ci NOT NULL,
  `elem_1` text collate utf8_polish_ci NOT NULL,
  `elem_2` text collate utf8_polish_ci NOT NULL,
  `elem_3` text collate utf8_polish_ci NOT NULL,
  `elem_4` text collate utf8_polish_ci NOT NULL,
  PRIMARY KEY  (`id`)
);