Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ->save() function generated by propel build? #67

Open
bushshrub opened this issue Aug 19, 2017 · 4 comments
Open

No ->save() function generated by propel build? #67

bushshrub opened this issue Aug 19, 2017 · 4 comments

Comments

@bushshrub
Copy link
Contributor

Hi, I'm relatively new to Propel. I setup my DB with propel init, and did propel build, which generated the models. However, when I tried to use the ->save() function, my IDE reports that the method does not exist. Does anyone know why this is so?

I'm using PHPStorm 2017.1.4

Also, my IDE also reports that another definition with the same name exists in the file, and commenting out the use myNameSpace\SubNameSpace\ModelName seemed to help.

@bushshrub
Copy link
Contributor Author

bump

@marcj
Copy link
Member

marcj commented Dec 3, 2017

In Propel3 active-record methods are optional. Set activeRecord="true" at <entity> or <database> to activate it.

@bushshrub
Copy link
Contributor Author

bushshrub commented Dec 4, 2017

What if I don't activate it? What is the difference? And if I don't enable it, how do I persist objects to the database.

@cristianoc72
Copy link
Member

In the data mapper pattern, the persistance logic is not contained into the entity, so you should use the session objectd to do it:

// create the $configuration manually
$configuration = new Configuration(‘./path/to/propel.yml’);

$session = $configuration->createSession();

$car1 = new Car(‘Ford Mustang’);
$session->persist($car);
$car2 = new Car(‘Ferrari Testarossa’);
$session->persist($car);

$session->commit(); //Save the objects to the database, following the unit-of-work pattern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants