PHP ORM" Spot"为简单的用例抛出异常

时间:2017-09-18 15:10:18

标签: php orm

我只是把ORM" Spot"并创建了一个只有1个字段的简单实体,创建了correspoding表,并按照文档为该实体的实例插入一行。我一直在Spot的Entity类的set函数中得到一个ArgumentCountError,但无论如何都会保存Entity。这是我正在使用的代码。

    $data = [
        'firstName' => $this->request->getParameter('fname'),
        'lastName' => $this->request->getParameter('lname'),
    ];

    $cfg = new \Spot\Config();
    // MySQL
    $cfg->addConnection('mysql', 'mysql://TestUser:1234@localhost/bookstore');

    $spot = new \Spot\Locator($cfg);

    $userMapper = $spot->mapper('Example\Models\User');

    $entity = $userMapper->build([
        'firstName' => $data['firstName']
    ]);

    $result = $userMapper->insert($entity);

和实体:

class User extends Entity
{
    protected static $table = 'user';

    public static function fields()
    {
        return [
            'firstName'=> ['type' => 'string']
        ];
    }
}

0 个答案:

没有答案