我有一个有多个子类的类
public class BaseClass{}
public class SubClass : BaseClass
{
public SomeClass someClass { get; set; }
}
我有另一个类SomeClass,它具有一个唯一的约束,这个约束通常会通过创建一个新类而被违反。这就是我想要做的:
SubClass toBeSaved = new SubClass(){
someClass = new SomeClass("UniqueConstraintForSomeClass")
};
session.Save(
我有一个有效的create方法,但是它无法创建它的关系:
public function create(array $article, string $note)
{
$art = $this->article->create($article);
print($art->id) // this line is for helping me to know if id is successfully generated. It works!
$this->article->note()->create([
'
哪一个更有意义?
这一个可能更容易使用,因为您只需要做$文章->save();
<?php
class Article
{
private $author;
public function __constructor(Author $author)
{
$this->author = $author;
}
public function save()
{
$database = ServiceLocator::getDatabase();
//save article lo