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
9
votes
2 answers

Increment value in database using Propel

I'm new to propel, and I'm looking for a way to increment a value in my MySQL database, without having to do a full read-update-write cycle. Such as this: UPDATE books SET popularity = popularity + 1 WHERE id = 123 Of course I can do: $book = new…
9
votes
1 answer

Laravel (Eloquent) Table || Peer equivalent

Propel uses Peer classes, and doctrine used Table classes as a way to manipulate respective objects and object properties, without having to pollute the actual object with static methods. After cursory glance of the laravel (eloquent) docs, I…
Mike Purcell
  • 19,847
  • 10
  • 52
  • 89
9
votes
2 answers

Propel ORM - Joining unrelated tables

How does this SQL statement translate into Propel (1.6.3)? SELECT * FROM table_a JOIN table_b With tableA and tableB sharing no Foreign Keys and having no relationships defined. TableAQuery::create()->join('tableB') doesn't work since Propel…
Thomas
  • 198
  • 1
  • 8
9
votes
4 answers

Select all fields where fieldone is not equal to null + Propel

I have a question about using the propel ORM and creating a query. I have a table "locations" with fields: location sublocation postcode street number Now I want to select all the locations where the location field IS NOT equal to 'null'. How…
nielsv
  • 6,540
  • 35
  • 111
  • 215
9
votes
5 answers

How to get object by "id" from propel object collection?

I'm using Propel 1.6 and I'm not sure how to get an object (given its "id" attribute value) from a propel object collection. I could not find a straight answer in Propel's documentation (PropelCollection methods do not seem applicable?). For…
RayOnAir
  • 2,038
  • 2
  • 22
  • 33
9
votes
1 answer

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

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…
RayOnAir
  • 2,038
  • 2
  • 22
  • 33
8
votes
3 answers

Count and group-by with Propel

In Doctrine I can do: public function getCount() { $q = $this->createQuery('q') ->select('*') ->addSelect('count(q.name) as count') ->groupBy('q.name') ->orderBy('count DESC'); …
Johan Dannenberg
  • 81
  • 1
  • 1
  • 2
8
votes
2 answers

Symfony2 + Propel Collection undefined offset: 2

We have created a collection using propel and Symfony2 forms. We can save the form without any problems and we can add a second option using the collection. If we then save and then try to add a 3rd collection in we get the following error: Notice:…
Liam Sorsby
  • 2,912
  • 3
  • 28
  • 51
7
votes
1 answer

phing installed but "not found" and not in pear list

I'm attempting to install the Propel ORM on CentOS which has a dependency for phing. I've run the following which was succesful: pear channel-discover pear.phing.info pear install phing/phing pear install Log However when I run ./propel-gen as is…
Bendihossan
  • 2,407
  • 5
  • 22
  • 25
7
votes
4 answers

Using ORM classes directly from the controller in MVC, bad practice?

I've recently delved into using an ORM in my CodeIgniter application and one i've gone for is Propel. Now this gives me the power to basically use Propels classes as the 'Model' but is this bad practive? So my controller code would be as…
phpNutt
  • 1,529
  • 7
  • 23
  • 40
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
7
votes
2 answers

Propel - No connection defined for database "default"

I'm struggling to get propel to connect to a database. I've created mapped the classes and table maps using propel reverse "...", and created the following structure: propel.ini [propel] # A better Pluralizer propel.builder.pluralizer.class =…
wonea
  • 4,783
  • 17
  • 86
  • 139
7
votes
1 answer

Adding related items using Sonata Admin and Propel

I have Sonata Admin up and running Using Propel with two models/Admin class defined; Portfolio and Image, where a portfolio item can have many images. I have an ImageAdmin that allows for the images to be uploaded, associated with a portfolio item…
Rooneyl
  • 7,802
  • 6
  • 52
  • 81
7
votes
1 answer

Do not work ParamConverter with "fos_rest.request_body" converter

I'm trying to use FOSRestBundle's request body converter but my current implementation doesn't seem to work. I am using Symfony2, Propel, AngularJS (it sends data to server) What am i doing wrong? config.yml: fos_rest: routing_loader: …
Dmitry Skryabin
  • 1,584
  • 2
  • 10
  • 15
7
votes
4 answers

Use of closing database connection in php

I was always in assumption that it is always a good practice to close database connection, regardless of database/ORM, like mysql_close(), Propel::close() etc. With reference to one of my other question and some other research on Internet, I came to…
Kapil Sharma
  • 10,135
  • 8
  • 37
  • 66
1
2
3
77 78