Questions tagged [propel]

Propel is an open-source object-relational mapping (ORM) for PHP 5. It allows you to access your database using a set of objects, providing a simple API for storing and retrieving data. There are two major versions, 1 and 2.

Propel is an open-source object-relational mapping (ORM) for PHP 5.

It allows you to access the records in your database using a set of OOP objects, providing a simple API for basic CRUD operations. To accomplish this, Propel ORM includes a generator component which uses source code generation to build PHP classes based on a data model definition written in XML (or reverse-engineered from an existing database).

Propel also includes a runtime component which manages connections, transactions, and any idiosyncratic rules that describe the workings of the RDBMS being used with Propel.

In addition to being open source, the code as implemented in a project is extendable with behaviors which alter the generated class structure and by working with the one-time generated model classes themselves which extend the base Active Record classes.

It is also an integral part of the PHP framework Symfony and was the default ORM up to and including version 1.2.


Documentation:

1161 questions
4
votes
3 answers

Importing HUGE JSON-encoded arrays without hitting memory constraints

I have a file which contains two JSON arrays; one is holding the column names which has 4 values and another array which contains 10,000+ record values. I am using Symfony and Propel; while using json_decode it throws an allowed memory size…
Arasu
  • 2,078
  • 6
  • 40
  • 67
4
votes
4 answers

symfony - returning JSON from a peer method call in an action

I have some code that checks a parameter and the calls a peer method to get me items from the DB. What I need to get is these items in JSON. My peer method is like: public static function searchFromRequest($word) { $c = new Criteria(); …
terrid25
  • 1,926
  • 8
  • 46
  • 87
4
votes
1 answer

setting propel by default to date format getDate("Y-m-d"), to work better with zend toArray()

My query returns an object that has a date field $obj = ObjectQuery::create()->findPK(11); var_dump($obj) shows me the date field as yyyy-mm-dd like it is in the database $obj->getThedate(); changes the format to mm/dd/yy which I don't want to…
jblue
  • 4,390
  • 4
  • 46
  • 79
4
votes
1 answer

foreign-key on a table not in the database, with ORM

I have a static table entry that's shared by several databases/website. By static, I mean the data is read but never updated by the websites. Currently, all websites are served from the same server but that may change. I want to minimize the need…
sami
  • 7,515
  • 8
  • 33
  • 37
4
votes
1 answer

Propel ORM: Calculating Average of a column

I have a product object and I have rating Objects, which represent a rating about a product. A rating has a property named "value", which is an Integer from 1 to 5. For a given product I would like to get the average of the values of all ratings. I…
Pascal Klein
  • 23,665
  • 24
  • 82
  • 119
4
votes
9 answers

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…
GeoffreyF67
  • 11,061
  • 11
  • 46
  • 56
4
votes
1 answer

Propel Syntax Error Received when using reserved keywords in table or column names

Is there a way to have Propel automatically escape column names which are reserved words when adding/updating a row? Right now I have a column named 'order' and when I try to update using $row->setOrder(1)->save(); I get a syntax error "PHP Fatal…
knsheely
  • 543
  • 5
  • 13
4
votes
3 answers

Propel ORM: Order By FIELD

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?
Lionel
  • 387
  • 3
  • 18
4
votes
1 answer

Propel 2: Using a subquery as the value for a virtual column

We have a table containing all our products and a separate table containing all ordered items. The ordered items are basically a copy of the product that has been ordered, with a relation to their source product (via foreign key) and additional data…
Subsurf
  • 1,256
  • 1
  • 17
  • 28
4
votes
3 answers

Does Propel know when an object has been soft-deleted, so that child entities could still show their deleted parent?

I am soft-deleting objects in a MySQL database and using the Propel ORM. I have gotten soft-deleting to work, but at the cost of losing my enforced parent-child relationships, since the actual rows are not being deleted. Is there any way for Propel…
Nick
  • 1,049
  • 2
  • 8
  • 12
4
votes
1 answer

Symfony2 and Propel bundle: add additional filter to the Propel param converter

I am using a Propel parameter converter in one of my controller: (Symfony 2.4.2 + Propel 1.7) * @ParamConverter("center", converter="propel", class="MyCompany\Bundle\CoreBundle\Model\Center") It's work well, but I'd like to add additional filters,…
COil
  • 7,201
  • 2
  • 50
  • 98
4
votes
1 answer

How do I reduce repetitive code when inserting the same metadata into identical columns over multiple tables?

My goals: Follow database-normalization. Ability to track changes in my tables. Ability to restore the state of my database from a given point in time, e.g. last month. Separate the code that is processing the data so that the input can come either…
haakim
  • 43
  • 1
  • 1
  • 3
4
votes
4 answers

Propel ORM including MAX in criteria

I am writing a query using the Propel ORM The query is of the form: select * from some_table where some_table.created_at = (SELECT MAX(some_table.created_at) from some_table); I got this far: $c = new Criteria(); …
Stick it to THE MAN
  • 5,621
  • 17
  • 77
  • 93
4
votes
2 answers

Strategies for cleanly extending Propel Models in Symfony2?

I want to do this: // Model class namespace Bookshop\Inventory\Model; use Core\Inventory\Model\Product as BaseProduct; class Book extends BaseProduct { // ... } // Query class namespace Bookshop\Inventory\Model; use…
Mathew
  • 8,203
  • 6
  • 37
  • 59
4
votes
2 answers

Select specific column(s) using Propel without aliasing

I'm having quite a bit of trouble rewriting a simple query using methods provided by Propel 1.6. The query is as follows: SELECT type_id, COUNT(id) as `count` FROM visit GROUP BY type_id; Using Propel, I've written the following: $visitCount =…
billyonecan
  • 20,090
  • 8
  • 42
  • 64