propel

Search strategies in ORMs

I am looking for information on handling search in different ORMs. Currently I am redeveloping some old application in PHP and one of requirements is: make everything or almost everything searchable, so user just types "punkrock live" and the app finds videos clips, music tracks, reviews, upcoming events or even user comments labeled th...

Symfony app - how to add calculated fields to Propel objects?

What is the best way of working with calculated fields of Propel objects? Say I have an object "Customer" that has a corresponding table "customers" and each column corresponds to an attribute of my object. What I would like to do is: add a calculated attribute "Number of completed orders" to my object when using it on View A but not on...

How do you check and see if a propel object has an i18n record?

I'm using symfony and propel, and I'm trying to invoke a specific culture on an object and output some fields of that object to the screen in that specific culture. However, if the object's mapped database record doesn't have those fields in that specific culture, I would like it to default to the base culture (in this case, en_US) I'm ...

How to use MySQL functions in Propel

I want to select records that are 1 month old or newer. The query is: SELECT * FROM foobar WHERE created_at > DATE_SUB(curdate(), INTERVAL 1 MONTH) Using Propel in Symfony, I do: $c = new Criteria $c->add(FoobarPeer::CREATED_AT, "DATE_SUB(curdate(), INTERVAL 1 MONTH)", Criteria::GREATER_THAN); What Propel generates is: SELECT...

propel-gen's "convert-conf" target fails

I'm trying to generate my models from a schema.xml file on OSX 10.5 with the latest versions of PHP & Propel 1.3 & Phing. All the model classes actually get created, then it just dies, right at the last step. I have already tried chmod -R 777 ./application/config but that didn't help. I have also tried both propel-gen ./ reve...

Outer Join using Propel 1.2?

I'm trying to do an Outer Join in Symfony. Here's the bit of code that seems like it would work if Criteria supported OUTER_JOIN: $user = sfContext::getInstance()->getUser(); $petCriteria = new Criteria(); $petCriteria->add(PetInfoPeer::ACCOUNT_ID, $user->getProfile()->getAccountId()); $petCriteria->add(LostPetPeer::PET_INFO_ID, Criteri...

What do you consider before refactoring code?

I've got an application that just shipped. Since I wrote it, I've learned about amfphp and propel. Both would be 'nice' to be used in the application but I can't say that it would be required at this point. What types of things do you consider before you refactor code? G-Man ...

Symfony Propel criteria

Hi, Is there any possible way to convert the MySQL object into criteria object? I tried this query "select p.disrepid, p.subject, p.body, c.disrepid as disrepid1, c.subject as subject1, c.body as body1 from discusreply as p, discusreply as c where p.distopid='.$this->id.' and (c.disrepid = p.parentid or c.parentid = p.distopid) order by...

deleting queries in mySQL

Hi, Reading the bottom of this document, specifically: "You can still retrieve properties of deleted objects, but you cannot save deleted objects." what the heck? how?...is it only if you enable a setting? http://propel.phpdb.org/docs/user_guide/chapters/ManipulatingObjects.html#ManipulatingObjects.Deleting explanation would be appr...

Database Sharding Support in Propel

Just wonder how good is Propel's support for database sharding? I am thinking about creating my application in PHP, using MySQL as the database server and Propel as the ORM. I figure out that it may be good to keep the architecture scalable right from the start, just in case my application takes off. What's your take? ...

Export MySQL Workbench data model directly to Schema YML in Propel/ Symfony

Is there any plugin that directly exports MYSQL Workbench data model directly to YML for Propel consumption? ...

Propel with Schema.xml

Is it possible to generate model in Propel using Schema.xml, instead of Schema.yml? There was once upon a time when xml was used for database generation in Propel, but it had been dropped in favor of yml. I should go for yml if I were handcoding my database schema, but now since I directly export my database schema from MySQL workbench ...

Propel - SQL: extract a month from a date

I'm trying to build a query with propel Criteria to get all Foo's in a given month. For example I want all Foo's in March. In regular SQL I would build a query like this: SELECT * FROM FooPeer WHERE MONTH(startDate) = 3 Any Idea how I can implement the "MySQL Month-function within a Criteria Object" ? $c = new Criteria(); $c -> add(...

How do you do Unit Testing With an App that Uses an ORM?

I've looked through the various questions on unit testing but can't find one that specifically answers this question. I've got several PHP classes that contain functions that look like this: static function _setSuspended($Suspended, $UserID) { try { $con = Propel::getConnection(); $c1 = new Crit...

Mutliple criteria for single field in symfony?

I'm trying to define multiple criteria for a single field in symfony, but every time I define a second criterion, it overwrites the previous one. Here is an example of my code: # build query to fetch search results $c = new Criteria(); # set minimum price if($request->getPostParameter('price_from') > 0) { $c->add(HomeMode...

How can I write a SQL count with group by clause using Propel ORM in Symfony?

How can I write the following SQL query using the Propel ORM? SELECT species, COUNT(*) FROM Bird GROUP BY species; ...

Concurrency Problem

Hello, I'm having what seems to be a concurrency problem while using MySQL and PHP + Propel 1.3. Below is a small example of the "save" method of a Propel object. public function save(PropelPDO $con = null) { $con = Propel::getConnection(); try { $con->beginTransaction(); sleep(3); // ignore this, used for testi...

MySQL Multiple COUNT group

I have this query but I don't know if it's possible to do this. Basically, I'm doing a count and group by each column. However, I want to show the count DESC/ASC. Since they're different columns, I can I achieve this? Here is my query: SELECT flags.ID, flags.COMMENT_ID, flags.CONTENT_ID, flags.USER_ID, flags.WALLPOST_ID, flags.FLAGGED_B...

In symfony, how to set the value of a form field?

I'm overriding my doSave() method to basically do the following: I have a sfWidgetFormPropelChoice field that the user can either choose from, or type a new option. How can I change the widget's value? Or maybe I am approaching this the wrong way. So here is how I overrode the doSave() method: public function doSave($con = null) { // S...

Make all form validation errors show up at top in symfony?

I think I may be missing something here that should be relatively common. How can I make all form validation errors, including field-bound errors, show up at the top of the form (global)? ...