Quick links: Content - sections - sub sections
EN

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revisionBoth sides next revision
en:tutorial:using-dao [2007/01/13 21:28] – created doublefaceen:tutorial:using-dao [2007/01/13 21:37] doubleface
Line 12: Line 12:
  
 In the DAO XML file, you can also define your own access methods to data, and jDao will generate the corresponding methods and requests in the DAO factory. In the DAO XML file, you can also define your own access methods to data, and jDao will generate the corresponding methods and requests in the DAO factory.
 +
 +===== creating a first DAO =====
 +
 +
 +You have command to be able to create a DAO file, based on an existing table. It has this following syntax: 
 +
 +   createdao //module_name// //dao_name// //table_name//
 +
 +
 +A news table has been created before, and we will create a DAO named "news", in the "news" module. Then type: 
 +
 +<code bash>
 +   php jelix.php createdao news news news
 +</code>
 +
 + 
 +You obtain an actu.org/modules/news/daos/news.dao.xml file. (you can of course create it by hand). 
 +
 +Its content is what follows :
 +<code xml>
 +<?xml version="1.0" encoding="iso-8859-1"?>
 +<dao xmlns="http://jelix.org/ns/dao/1.0">
 +  <datasources>
 +    <primarytable name="news" realname="news" primarykey="id_news" />
 +  </datasources>
 +  <record>
 +    <property name="id_news" fieldname="id_news" datatype="autoincrement"/>
 +    <property name="sujet" fieldname="sujet" datatype="string"/>
 +    <property name="texte" fieldname="texte" datatype="string"/>
 +    <property name="news_date" fieldname="news_date" datatype="date"/>
 +  </record>
 +</dao>
 +
 +</code>
 +
 +This is a very simple content, and of course there are other attributes and tags to enrich it and customize it. For the moment, we will leave it there.

en/tutorial/using-dao.txt · Last modified: 2007/09/17 22:42 by 127.0.0.1

Recent changes RSS feed Creative Commons License