cvs: pear /MDB2_Schema/docs/examples parse.php schema.xml
| From: | Igor Feghali | Date: | Tue, 15 Aug 2006 20:06:17 +0000 |
| Subject: | cvs: pear /MDB2_Schema/docs/examples parse.php schema.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-41615@lists.php.net to get a copy of this message | ||
ifeghali Tue Aug 15 20:06:17 2006 UTC
Added files:
/pear/MDB2_Schema/docs/examples parse.php schema.xml
Log:
Example of the new XML syntax (better support for INSERTs, support from UPDATEs and DELETEs)
http://cvs.php.net/viewvc.cgi/pear/MDB2_Schema/docs/examples/parse.php?view=markup&rev=1.1
Index: pear/MDB2_Schema/docs/examples/parse.php
+++ pear/MDB2_Schema/docs/examples/parse.php
<?php
// +----------------------------------------------------------------------+
// | PHP versions 4 and 5 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, |
// | Stig. S. Bakken, Lukas Smith |
// | All rights reserved. |
// +----------------------------------------------------------------------+
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
// | API as well as database abstraction for PHP applications. |
// | This LICENSE is in the BSD license style. |
// | |
// | Redistribution and use in source and binary forms, with or without |
// | modification, are permitted provided that the following conditions |
// | are met: |
// | |
// | Redistributions of source code must retain the above copyright |
// | notice, this list of conditions and the following disclaimer. |
// | |
// | Redistributions in binary form must reproduce the above copyright |
// | notice, this list of conditions and the following disclaimer in the |
// | documentation and/or other materials provided with the distribution. |
// | |
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
// | Lukas Smith nor the names of his contributors may be used to endorse |
// | or promote products derived from this software without specific prior|
// | written permission. |
// | |
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// | POSSIBILITY OF SUCH DAMAGE. |
// +----------------------------------------------------------------------+
// | Author: Igor Feghali <ifeghali@php.net> |
// +----------------------------------------------------------------------+
//
// $Id: parse.php,v 1.1 2006/08/15 20:06:16 ifeghali Exp $
//
include 'MDB2/Schema.php';
include 'MDB2/Schema/Parser.php';
$parser =& new MDB2_Schema_Parser(array());
$parser->setInputFile("schema.xml");
$result = $parser->parse();
?>
<pre>
<?
if (PEAR::isError($schema->error))
{
print_r($parser->error);
}
else
{
print_r($parser->database_definition['tables']['Example']);
}
?>
</pre>
http://cvs.php.net/viewvc.cgi/pear/MDB2_Schema/docs/examples/schema.xml?view=markup&rev=1.1
Index: pear/MDB2_Schema/docs/examples/schema.xml
+++ pear/MDB2_Schema/docs/examples/schema.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
<name>DataBase</name>
<table>
<name>Example</name>
<declaration>
<field>
<name>foo</name>
<type>integer</type>
<unsigned>true</unsigned>
</field>
<field>
<name>foolish</name>
<type>integer</type>
<unsigned>true</unsigned>
</field>
<field>
<name>birthday</name>
<type>timestamp</type>
</field>
</declaration>
<initialization>
<insert>
<field>
<name>foo</name>
<value>2</value>
</field>
<field>
<name>birthday</name>
<function>
<name>now</name>
</function>
</field>
<field>
<name>foolish</name>
<expression>
<value>3</value>
<operator>PLUS</operator>
<column>foo</column>
</expression>
</field>
</insert>
<update>
<field>
<name>foo</name>
<value>10</value>
</field>
<where>
<expression>
<column>foo</column>
<operator>EQUAL</operator>
<value>2</value>
</expression>
</where>
</update>
<delete>
<where>
<expression>
<column>foolish</column>
<operator>LESS THAN</operator>
<value>15</value>
</expression>
</where>
</delete>
</initialization>
</table>
</database>