propel

Which ORM to use with Symfony2? [closed]

纵饮孤独 提交于 2019-12-04 00:58:06
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I'm starting a new project with Symfony2 and I'm not really sure which ORM to choose. I've heard some bad things about Doctrine2, especially when it comes to inheritance and DQL. It seems like Propel is back from the dead, but on the

How to add an autocomplete field in a Symfony2 form for a collection and using Propel?

£可爱£侵袭症+ 提交于 2019-12-03 07:36:24
问题 I'm using Symfony 2.1 forms with PropelBundle and I'm trying to refactor a form that had a drop-down list of objects (to select from) to instead use a jquery autocomplete field (working with AJAX). For the dropdown list I was using the following code (which worked perfectly for the drop-down) in my form type: $builder->add('books', 'collection', array( 'type' => 'model', 'options' => array( 'class' => 'MyVendor\MyBundle\Model\Book', 'property' => 'title', ), 'allow_add' => true, 'allow_delete

propel pseudo column sorting

浪子不回头ぞ 提交于 2019-12-02 10:06:30
问题 Basically I want to make a pseudo column by which I'll sort. This is my SQL Query SELECT I.*, ((I.width*175)/I.height) as relativeWidth FROM Image I order by relativeWidth asc How can I do it in propel without writing direct SQL ? and I don't want to make a view and query it. 回答1: Are you using Criteria (the old way of creating a where clause)? If so you can simply do: $c = new Criteria(); $c->addSelectColumn( '((' . IPeer::WIDTH . '*175)/' . IPeer::HEIGHT . ') AS relativeWidth' ); $c-

Rewriting Not In Sub-Select as Join for Propel

故事扮演 提交于 2019-12-02 07:40:56
问题 Given the following schema: person: id: ~ group: id: ~ group_membership: person_id: ~ group_id: ~ I am attempting to find members not within a certain group using Propel's Criteria, which the following SQL will do: SELECT * FROM person WHERE id NOT IN ( SELECT person_id FROM group_membership WHERE group_id = 1 ); Unfortunately, Propel doesn't support sub-selects. It's possible to perform the sub-select first and pass it directly as an array, but I would rather do it in one call. I found this

Rewriting Not In Sub-Select as Join for Propel

两盒软妹~` 提交于 2019-12-02 04:22:23
Given the following schema: person: id: ~ group: id: ~ group_membership: person_id: ~ group_id: ~ I am attempting to find members not within a certain group using Propel's Criteria, which the following SQL will do: SELECT * FROM person WHERE id NOT IN ( SELECT person_id FROM group_membership WHERE group_id = 1 ); Unfortunately, Propel doesn't support sub-selects. It's possible to perform the sub-select first and pass it directly as an array, but I would rather do it in one call. I found this article , which suggests using a custom criteria or converting it to a join. Is it possible to convert

UNION query with Propel ORM

青春壹個敷衍的年華 提交于 2019-12-01 16:18:09
问题 I'm trying to create a UNION query using the Propel ORM e.g $criterion1 UNION $criterion2 Does anyone know how to do this? 回答1: You cannot create a union query using Criteria. Instead, you can create the SQL string yourself, and use it to hydrate the objects. If you still want to use Criteria to build both parts of the union query, you can call BasePeer::createSelectSql(Criteria $criteria, array &$params) . This will return an SQL string with ? in the places of the values that need to be set

Symfony task - memory leak

和自甴很熟 提交于 2019-12-01 11:49:27
I wrote a symfony task to fill a database of sample data. Here's a sample piece of code: gc_enable(); Propel::disableInstancePooling(); public function test() { for($i = 0; $i < 10000; $i++) { $this->doIt($i); } } public function doIt($i) { $user = new User(); $user->setUsername('user' . $i . "@example.com"); $user->setPassword('test'); $user->setFirstName('firstname' . $i); $user->setLastName('surname' . rand(0, 1000)); $user->save(); $user->clearAllReferences(true); $user = null; gc_collect_cycles(); } How can I limit the use of memory? j0k You have some good tips in an other thread on SO .

Continuous Integration, best practice to input actual test data into database, using Propel ORM

家住魔仙堡 提交于 2019-12-01 08:28:27
I used Propel ORM to duplicate a table schema, in order to do continuous integration, but Propel only gets me a fully fleshed out schema, it doesn't get me test data (or basic necessary data at all). How do I get the data from a live/test database with a version controlled propel-gen Propel ORM ecosystem? They say that "best practice" in anything at all doesn't exist - it's so subjective that one ought to settle for one of several forms of "good practice" instead. I think the below qualifies for that label — and ultimately it works well for me. I've been using PHPUnit for about a year, and

Continuous Integration, best practice to input actual test data into database, using Propel ORM

北城余情 提交于 2019-12-01 06:06:29
问题 I used Propel ORM to duplicate a table schema, in order to do continuous integration, but Propel only gets me a fully fleshed out schema, it doesn't get me test data (or basic necessary data at all). How do I get the data from a live/test database with a version controlled propel-gen Propel ORM ecosystem? 回答1: They say that "best practice" in anything at all doesn't exist - it's so subjective that one ought to settle for one of several forms of "good practice" instead. I think the below

How to use MySQL functions in Propel

限于喜欢 提交于 2019-12-01 05:56:37
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 * FROM foobar WHERE created_at > 'DATE_SUB(curdate(), INTERVAL 1 MONTH)' - in other words, it puts the MySQL function in single quotes, which makes it a (meaningless) string and I get no records. What I've done for now is: $c->add(FoobarPeer::CREATED_AT, "created_at >