Questions tagged [propel2]

Propel2 is the next major version of an open-source Object-Relational Mapping (ORM) for PHP5. It allows you to access your database using a set of objects, providing a simple API for storing and retrieving data.

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

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:

68 questions
7
votes
4 answers

Is it possible to remove fields with *RECURSION* when using toArray() in Propel?

I am using Propel 2. I am hydrating objects through the relations, like so: $return = OrderQuery::create() ->joinWith('Customer') ->joinWith('Status') ->find() ->toArray(TableMap::TYPE_PHPNAME, true, [], true); The resulting Array…
LeonardChallis
  • 7,759
  • 6
  • 45
  • 76
5
votes
1 answer

Propel2 reconnect when MySQL server gone away

I have a long-running job, built using Propel2. However, sometimes it crashes with the infamous mysql server has gone away error. I'd like to recover from this error by reconnecting to the server, maybe after waiting a few seconds. Does anyone have…
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
3
votes
1 answer

Use PDO::MYSQL_ATTR_SSL_CA with Propel ORM

I'm trying to reverse engineer a database with Propel reverse command. The database I'm trying to connect to requires a SSL certificate, this is how I connect to it in my application: new PDO( 'mysql:host=localhost;dbname=blog', 'root', '',…
Tchoupi
  • 14,560
  • 5
  • 37
  • 71
3
votes
2 answers

Get ID of inserted row with Propel ORM when not using autoincremented IDs

Using Propel, I can save an object using $user = new User; $user->setName('Test'); $user->save(); $user->getId() will contain the ID of the inserted object. But this will only work if I use autoincremented ID values. Is there any way I can get…
James
  • 565
  • 2
  • 7
  • 17
3
votes
3 answers

Allowed memory size exhausted with Propel2 custom query

(updates at bottom) I'm trying to get the latest entry in my table called "VersionHistory", and since the ID is set to auto increment, I was trying to get the max id. Trying to stay away from sorting the whole table in descending order and taking…
user2317084
  • 301
  • 5
  • 15
2
votes
1 answer

Propel enum with validation

I have a user table with an enum field for gender with the options male / female. If I create a user an Exception is thrown if I try to set the gender to for example 'transgender'. Is it possible to allow setting transgender to 'transgender' and…
klaasjansen
  • 537
  • 1
  • 6
  • 20
2
votes
1 answer

Multi-tenant application with Propel ORM

I am currently a developer of a multi-tenant application in which there is a "master" database, which holds customer's data and is also used as a template, that is, it gets copied with a different name for each new customer, to hold its data. When…
Matteo Tassinari
  • 18,121
  • 8
  • 60
  • 81
2
votes
1 answer

propel 2.0 order by and populateRelation

Small question: how do I order a result when I'm using populateRelation: $object->populateRelation('OtherObject'); Thanks!
Remco
  • 172
  • 9
2
votes
4 answers

Propel adds CROSS JOIN to query when using an alias to JOIN tables

Trying to do a fairly simple query in Propel 2. I have a Person table and a Possession table - persons can have many possessions but only one of each possession type. So a person can have 1 book, 1 car, etc. I'm trying to write a query in Propel…
zeke
  • 3,603
  • 2
  • 26
  • 41
2
votes
1 answer

Using an SQL function when updating rows with Propel 2

I'm using Propel 2 and am trying to do a batch update of records. The following works as expected: //UPDATE animal SET species='Duck'; AnimalQuery::create()->update(['Species' => 'Duck']); However, I'm not sure what to do if I want to do something…
zeke
  • 3,603
  • 2
  • 26
  • 41
2
votes
2 answers

Propel2 diff detects non-existent changes with PostgreSQL

I'm using Propel2 ORM w/ PostgreSQL, this is my configuration: propel: database: connections: default: adapter: pgsql dsn: pgsql:host=localhost;port=5432;dbname=sps_db user: postgres …
Francis Straccia
  • 894
  • 1
  • 7
  • 20
2
votes
1 answer

How do I select specific columns on table join in propel?

I need to select specific set of columns from both the table using propel orm 2.0.0. The equivalent query is as below select b.name as brand_name, b.grade, d.name as dealer_name, d.number from brand as b join dealer as d on d.id = b.dealer_id; I am…
Ram Babu
  • 2,692
  • 3
  • 23
  • 28
2
votes
2 answers

Propel2: lowercase/camelCase keys when converting ObjectCollection toJSON()

How can we convert the keys of a toJson() returned object to lowercase or camelCase? Consider the following example: Query: $foo = FooQuery::create() ->filterByBar($bar) ->findOne() ->toJson(); Result: {"Id": 1,…
scripton
  • 228
  • 5
  • 15
2
votes
0 answers

Why is Propel is always setting created_at and updated at to the same value?

When I use PHP and the Propel ORM 2.0.0-dev to update a row in a table with the timestampable behavior, it always sets the created_at field as well as the updated_at field, which means that they're always the same. I want created_at to reflect when…
RCrowe
  • 363
  • 2
  • 9
1
2 3 4 5