czogori / propel-postgres-hstore-behavior
Storage of key-value items using Postgres hstore.
Installs: 2 528
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- propel/propel1: ~1.6
This package is not auto-updated.
Last update: 2024-12-21 14:01:59 UTC
README
Storage of key-value items using Postgres hstore.
Installation
First of all you have to install postgresql-contrib and create hstore extension.
CREATE EXTENSION hstore;
After that download code using composer:
{ "require": { "czogori/propel-postgres-hstore-behavior": "dev-master" } }
And put undermentioned entry to your propel.ini
or build.properties
configuration
file:
propel.behavior.hstore.class = path.to.PostgresHstoreBehavior
Usage
Table definition - schema.xml
file:
<table name="book" phpName="Book"> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/> <column name="title" type="varchar" size="255" required="true" /> <column name="extra_parameters" type="varchar" required="false" /> <behavior name="hstore"> <parameter name="column_name" value="extra_parameters" /> </behavior> </table>
Now you can use hstore behavior.
$book = new Book(); $book->setTitle('Foo and Bar'); // you can set params as array $book->setExtraParameters(array('language' => 'polish')); // or like this $book->setLanguage('polish'); $book->save(); echo $book->getLanguage(); echo $book->getExtraParameters('language');