jpganz18
jpganz18

Reputation: 5878

How can I get back the id of my object after save it on symfony 1.4?

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?

Upvotes: 0

Views: 1361

Answers (1)

gries
gries

Reputation: 1143

I depends on the ORM you are using:

For doctrine try:

$car->id; or $car->getId();

For propel only use:

$car->getId();

Note These are only default values, if you defined something else then 'id' as your primary key field use the one you defined in the getter.

Upvotes: 1

Related Questions