RE: [PEAR] Problem creating tables from XML with MDB
| From: | Merritt, Dave | Date: | Thu, 17 Apr 2003 14:55:19 +0000 |
| Subject: | RE: [PEAR] Problem creating tables from XML with MDB | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-4917@lists.php.net to get a copy of this message | ||
Okay, I corrected my code to use the MDB::loadFile('Manager') and I used the
reverse_engineer_xml_schema.php to generate a sample xml. When I use the
xml file with my updated code the browser just hangs.
Dave Merritt
dave.merritt@arvinmeritor.com
Here's my php code:
<?php
require_once('MDB.php');
MDB::loadFile('Manager');
$schema_file='test.xml';
$manager=new MDB_manager;
$dbinfo = array
(
"phptype"=>'mysql',
"username"=>'pdmweb',
"password"=>'pdmweb',
"hostspec"=>'localhost'
);
$manager->connect($dbinfo);
$success = $manager->updateDatabase($schema_file, $schema_file . ".before");
if (MDB::isError($success))
{
die ($success->getMessage());
}
else
{
echo 'Good connection<br>';
}
if(count($manager->warnings)>0)
echo "WARNING:\n",implode($manager->getWarnings(),"!\n"),"\n";
?>
And my reverse engineered XML:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
<name>pdmweb</name>
<create>1</create>
<table>
<name>admin2</name>
<declaration>
<field>
<name>tsid</name>
<type>timestamp</type>
<notnull>1</notnull>
<default>0000-00-00 00:00:00</default>
</field>
<field>
<name>name</name>
<type>text</type>
<length>50</length>
<notnull>1</notnull>
<default></default>
</field>
<field>
<name>description</name>
<type>text</type>
<length>255</length>
</field>
<field>
<name>icon</name>
<type>text</type>
<length>255</length>
</field>
<field>
<name>hidden</name>
<type>text</type>
<length>1</length>
<notnull>1</notnull>
<default>1</default>
</field>
<field>
<name>type</name>
<type>text</type>
<length>11</length>
<notnull>1</notnull>
<default>increment</default>
</field>
<index>
<name>tsid</name>
<field>
<name>tsid</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>name</name>
<field>
<name>name</name>
<sorting>ascending</sorting>
</field>
</index>
</declaration>
<initialization>
<insert>
<field>
<name>tsid</name>
<value>0000-00-00 00:00:00</value>
</field>
<field>
<name>name</name>
<value>test</value>
</field>
<field>
<name>description</name>
<value>test</value>
</field>
<field>
<name>icon</name>
<value>test.gif</value>
</field>
<field>
<name>hidden</name>
<value>1</value>
</field>
<field>
<name>type</name>
<value>increment</value>
</field>
</insert>
</initialization>
</table>
</database>
-----Original Message-----
From: Lukas Smith [mailto:smith@backendmedia.com]
Sent: Friday, April 11, 2003 7:48 PM
To: 'Merritt, Dave'; 'Pear General (E-mail)'
Subject: RE: [PEAR] Problem creating tables from XML with MDB
> From: Lukas Smith [mailto:smith@backendmedia.com]
> Sent: Saturday, April 12, 2003 1:34 AM
> > From: Merritt, Dave [mailto:Dave.Merritt@ArvinMeritor.com]
> > Sent: Friday, April 11, 2003 8:48 PM
>
> > I'm getting the following error when I try to run code to create new
> > tables
> > from an XML file using MDB:
> >
> > Fatal error: Undefined class name 'mdb' in c:\pear\MDB\manager.php
on
> line
> > 269
> >
> > The OOP stuff is new to me so I may be doing something wrong in my
> code,
> > but
> > I copied the examples in the documentation. Any help would be
> > appreciated.
>
> Sorry my fault.
> I need to update the online documentation with the version from CVS.
> I changed the way includes are handled in MDB.
Ok I hope I just updated everything correctly.
Tell me if you find any more errors. I fear there may be some more
lurking around. Also if you need some more usage examples you can take a
look at the various test scripts. For the manager there is also the
reverse_engineer_xml_schema.php script (or whatever mad name I gave it).
It is certainly quite ugly, but usefull nonetheless.
Finally I have linked to a php mag article on the documentation page
(lower left hand corner) which introduces people to what sets MDB apart
from DB.
Regards,
Lukas
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php