Skip to content

Using Propel as Model

World Wide Web Server edited this page Jul 4, 2012 · 16 revisions

Category:Libraries Category:Libraries::Database Category:Libraries::Model

Hi out there. I saw, that nobody has ever tried to use the propel framework for generating a model.

I will try to integrate the Propel-Framework in the next days, and will keep you up to date.

For all of you, who are interested in diggin into the propel framework can check out the website of them. The framework has been integrated already in other MVC-Frameworks like symfony, and deals very well with realtionships.

URL to the Propel-Framework: [url]http://propel.phpdb.org/trac/[/url]

[b]Installation[/b]

Installation of the Propel-Framework is quite easy with PEAR. Just execute the following statements: {{{

pear channel-discover pear.phpdb.org pear channel-discover pear.phing.info pear install --alldeps --force phpdb/propel_generator pear install --alldeps --force phpdb/propel_runtime }}} If you prefer to download and install the full package, refer to the installation manual of the Propel-Framwork. (see website)

[b]Describing the model in XML[/b]

An easy description of building a schema.xml for propel you'll find at the [url=http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/QuickStart]quick start guide of propel[/url]

As a short overview I'll give a short example as you'd could need for an authentication system:

{{{ <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

<table name="activations" description="Activation Table">
    <column name="activation_id" type="integer" required="true" primaryKey="true" description="Activation Id"/>
    <column name="identity_id" type="integer" required="true" description="associated identity Id"/>
    <column name="activationcode" type="varchar" size="255" required="true" description="Activation code"/>
    <column name="created" type="timestamp" required="true" description="when the activation request was generated"/>
    <foreign-key foreignTable="identity">
        <reference local="identity_id" foreign="identity_id"/>
    </foreign-key>
</table>

<table name="permissions" description="Permission Table">
    <column name="permission_id" type="integer" required="true" primaryKey="true" description="Permission Id"/>
    <column name="parent_id" type="integer" required="true" description="parent permission id"/>
    <column name="permissionname" type="varchar" size="255" required="true" description="Permissionname"/>
    <column name="created" type="timestamp" required="true" description="when the permission was created"/>
</table>

<table name="roles" description="Role Table">
    <column name="role_id" type="integer" required="true" primaryKey="true" description="Role Id"/>
    <column name="parent_id" type="integer" required="true" description="parent role id"/>
    <column name="rolename" type="varchar" size="255" required="true" description="Rolename"/>
    <column name="created" type="timestamp" required="true" description="when the role was created"/>
</table>

<table name="roles_permissions" description="Roles-Permission Mapping Table">
    <column name="role_id" type="integer" required="true" primaryKey="true" description="Role Id"/>
    <column name="permission_id" type="integer" required="true" primaryKey="true" description="Permission id"/>
    <foreign-key foreignTable="permissions">
        <reference local="permission_id" foreign="permission_id"/>
    </foreign-key>
    <foreign-key foreignTable="roles">
        <reference local="role_id" foreign="role_id"/>
    </foreign-key>
</table>
}}}

[b]Generating the model[/b]

[b]Runtime settings[/b]

[b]Using the generated model with CodeIgniter[/b]

Clone this wiki locally