0

I was reading that if I make for example

$car = new Car();
$car->set('name','my car');
$car->set('color','orange');
and so on...

and if i make $car->save();

after that I will be able to make $car->getCarId(); (in case the id field was mapped as CarId, Ive been trying this, but I get null everytime, and the info is persisted on the DB, I dont know how to retrieve that information, any idea how to do this?

4

1 回答 1

2

我取决于您使用的 ORM:

对于教义尝试:

$汽车->身份证;或 $car->getId();

仅用于推进:

$car->getId();

注意 这些只是默认值,如果您定义了其他内容,则“id”作为主键字段使用您在 getter 中定义的字段。

于 2013-05-15T07:51:27.843 回答