Re: New MDB2_Schema Parser
| From: | Gregory Beaver | Date: | Wed, 07 Feb 2007 20:03:54 +0000 |
| Subject: | Re: New MDB2_Schema Parser | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-45620@lists.php.net to get a copy of this message | ||
Igor Feghali wrote:
> Hi all,
>
> I have uploaded to CVS the first approach for the new MDB2_Schema parser.
> The old parser is unable to handle recursive tags, so the new parser
> extends XML_Serializer, allowing much greater flexibility in XML
> schema files.
>
> To start making use of it you need to download the latest CVS version
> and set MDB2_Schema option 'parser' to 'MDB2_Schema_Parser2' on
> Schema.php line 88 or on your own script.
>
> It is still only a draft so it needs lots of code optimization and
> etc. Note the following "code":
>
> foreach
>
> ($this->database_definition['tables'][$table]['declaration']['field']
> as $k => $v) {
> $nKey =
>
> $this->database_definition['tables'][$table]['declaration']['field'][$k]['name'];
>
>
> unset($this->database_definition['tables'][$table]['declaration']['field'][$k]['name']);
>
>
> $this->renameKey($this->database_definition['tables'][$table]['declaration']['field'],
>
> $k, $nKey);
> }
>
> $this->renameKey($this->database_definition['tables'][$table]['declaration'],
>
> 'field', 'fields');
>
>
> Known issues:
>
> <insert/>
> <update/>
> <insert/>
>
> is parsed to:
>
> [insert] => array with 2 element
> [update] => array with 1 element
>
> (we lose the original order)
>
> this is much critical in this situation:
>
> <function>
> <name>myfunc</name>
> <column>A</column>
> <value>foo</value>
> <column>B</column>
> </function>
>
> which is parsed to:
>
> Array
> (
> [name] => myfunc
> [column] => Array
> (
> [0] => A
> [1] => B
> )
>
> [value] => foo
> )
>
> also the last case currently doesn't works at all. when generating the
> SQL it would bind to:
>
> myfunc(Array, 'foo')
>
>
> Any comments or suggestions would be appreciated.
Hi Igor,
There are two ways around this. One is to nest <value> inside <column>
<column>
<name>A</name>
<value>foo</value>
</column>
The other is a hack:
<column1>A</column>
<value1>foo</value1>
<column2>B</column>
Obviously the first way is better.
As for insert/update/insert, I would suggest solving it with this xml:
<sql><insert/></sql>
<sql><update/></sql>
<sql><insert/></sql>
So you get:
array(
'sql' =>
array(
0 => array('insert' => ''),
1 => array('update' => ''),
2 => array('insert' => ''),
)
)
Greg