Menu

Configuration

Rodrigo

XML Configuration and Mapping

The main configuration file must be located in xml/rpersistence-config.xml.

You have to define your database settings and your xmls mapping files with their respective classes.

Here is an example:

<rpersistence></rpersistence>

<database>

    <!-- Firebird Database
    <driver>Firebird</driver>
    <hostname>localhost</hostname>
    <database>/var/lib/firebird/2.1/databases/rexample/rexample.fdb</database>
    <username>SYSDBA</username>
    <password>password</password>
    -->

    <!-- MySQL Database
    <driver>MySQL</driver>
    <hostname>localhost</hostname>
    <database>rexample</database>
    <username>root</username>
    <password>password</password>

    -->
</database>

<cache>

    <!-- Cache engine (Filecache|Memcache) -->
    <engine>Filecache</engine>

    <!-- Attributes required for Memcache
    <host>localhost</host>
    <port>11211</port>
    -->

</cache>

<!-- Logging (true|false)-->
<log>true</log>

<classes>
    <class location="entities/User.class.php"    mapping="User.mapping.xml" />
</classes>

There are only two drivers available at the moment. MySQL and Firebird.

For example we will create a the User class in entities/User.class.php.

~~~~~~

id; } public function setId($id) { $this->id = $id; } public function getUser() { return $this->user; } public function setUser($user) { $this->user = $user; } public function getPassword() { return $this->password; } public function setPassword($password) { $this->password = $password; } } ?>
<strong>Important!</strong> You have to implement getters and setters!


Then you have to create the mapping files inside the "xml" directory.

Here is the content of User.mapping.xml.

<class name="User" table="users">
<primarykey autoincrement="true">id</primarykey>
<fields>
<field>
id
<db>id</db>
<type>NUMBER</type>
</field>
<field>
user
<db>username</db>
<type>TEXT</type>
</field>
<field>
password
<db>passwd</db>
<type>TEXT</type>
</field>
</fields>
</class>

~~~~~~~

var indicates the class field and db the database column.

Types avaialable: TEXT, NUMBER and DATE.


MongoDB Logo MongoDB