propel

Propel ORM: Order By FIELD

只愿长相守 提交于 2019-12-07 07:11:27
问题 I'm trying to do a query with a custom "order by" with Propel 1.6 select * from myObject ORDER BY FIELD(id, 3, 11, 7, 1) this does not work: myObjectQuery::create() ->orderById($someIds) ->find() how can i do? 回答1: you can stack order-by's in order that you want: myObjectQuery::create() ->orderByField1 ->orderbyField3('desc') ->orderbyField2 ->find() Try that. Update 2: $con = Propel::getConnection(); $query = 'SELECT COUNT(t1.user) AS users, t1.choice AS lft, t2.choice AS rgt FROM choice t1

Is Propel's fromArray/fromJSON feature safe from SQL injection?

怎甘沉沦 提交于 2019-12-07 04:16:54
问题 The Propel ORM documentation mentions a neat import/export feature using functions like fromArray and fromJSON, that should allow something like this: $foo = new Widget(); $foo->fromArray($_POST); $foo->save(); /* Aaand you're done! */ ...but the documentation doens't mention if using fromArray this way is supposed to be safe, i.e. if fromArray can handle untrusted input. My guess would be that it's all right - the default setters are injection-proof, and the whole deal is based on PDO - but

Propel 1.6 - Configuration Example?

爱⌒轻易说出口 提交于 2019-12-06 21:25:30
I'm new to using Propel ORM. I have generated code and am now trying to integrate the runtime with my PHP project. I am struggling with initializing the main Propel class. It appears that the usage should be: require_once('propel/runtime/lib/Propel.php'); Propel::configure('/path/to/runtime/config.php'); Propel::initialize(); I cannot find any documentation on what the contents on the runtime configuration should be, other than this: http://www.propelorm.org/wiki/Documentation/1.6/RuntimeConfiguration However, this document shows an XML file, not a PHP file. Any ideas? You need to actually run

Twig instanceof for inheritance objects

时光总嘲笑我的痴心妄想 提交于 2019-12-06 17:07:37
问题 I am using the following feature from propel http://www.propelorm.org/documentation/09-inheritance.html. I am also using Symfony2 and Twig I have a class structure using the above feature that looks something like this class Event {} class Birthday extends Event {} class Walking extends Event {} now I pass an event object to a twig template and I want to know what type of event it is For instance I want to display an image of a cake if its a birthday and I want to display map routes if its

Adding custom columns to Propel model?

混江龙づ霸主 提交于 2019-12-06 09:26:23
问题 At the moment I am using the below query: $claims = ClaimQuery::create('c') ->leftJoinUser() ->withColumn('CONCAT(User.Firstname, " ", User.Lastname)', 'name') ->withColumn('User.Email', 'email') ->filterByArray($conditions) ->paginate($page = $page, $maxPerPage = $top); However I then want to add columns manually, so I thought this would simply work: foreach($claims as &$claim){ $claim->actions = array('edit' => array( 'url' => $this->get('router')->generate('hera_claims_edit'), 'text' =>

Performing Join with Multiple Criteria in Propel 1.5

二次信任 提交于 2019-12-06 06:48:56
问题 This question follows on from the questions here and here. I have recently upgraded to Propel 1.5, and have started using it's Query features over Criteria. I have a query I cannot translate, however - a left join with multiple criteria: SELECT * FROM person LEFT JOIN group_membership ON person.id = group_membership.person_id AND group_id = 1 WHERE group_membership.person_id is null; Its aim is to find all people not in the specified group. Previously I was using the following code to

Symfony2 Forms - Selected Value in Dropdown using Propel ModelType

梦想与她 提交于 2019-12-06 06:35:38
问题 I'm trying to set the selected value of a 'model' (ModelType from the Symfony Propel Bridge) form type and I'm failing miserably. There is Product table with the following structure: id, name, category_id Example data would be: id => 1, name => 'Test', category_id => 3 Another table holds the Category data, so category_id is a foreign key. id => 1, name => 'Category 1' id => 2, name => 'Category 2' id => 3, name => 'Category 3' The form type I'm working with is: $builder->add('category_id',

Propel ORM: Order By FIELD

孤街醉人 提交于 2019-12-05 17:30:28
I'm trying to do a query with a custom "order by" with Propel 1.6 select * from myObject ORDER BY FIELD(id, 3, 11, 7, 1) this does not work: myObjectQuery::create() ->orderById($someIds) ->find() how can i do? you can stack order-by's in order that you want: myObjectQuery::create() ->orderByField1 ->orderbyField3('desc') ->orderbyField2 ->find() Try that. Update 2: $con = Propel::getConnection(); $query = 'SELECT COUNT(t1.user) AS users, t1.choice AS lft, t2.choice AS rgt FROM choice t1 iNNER JOIN choice t2 ON (t1.user = t2.user) WHERE t1.choice IN (?, ?) AND t2.choice IN (?, ?) GROUP BY t1

Which ORM to use with Symfony2? [closed]

此生再无相见时 提交于 2019-12-05 15:04:00
问题 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,

Is Propel's fromArray/fromJSON feature safe from SQL injection?

北战南征 提交于 2019-12-05 09:04:54
The Propel ORM documentation mentions a neat import/export feature using functions like fromArray and fromJSON, that should allow something like this: $foo = new Widget(); $foo->fromArray($_POST); $foo->save(); /* Aaand you're done! */ ...but the documentation doens't mention if using fromArray this way is supposed to be safe, i.e. if fromArray can handle untrusted input. My guess would be that it's all right - the default setters are injection-proof, and the whole deal is based on PDO - but I'd like to be sure. Propel not only uses PDO for the queries, it also utilizes Prepared Statements via