MDB2_Schema : how to specify auto_increment ? (and other questions)
| From: | Lassiege Hugo | Date: | Fri, 30 Sep 2005 14:56:14 +0000 |
| Subject: | MDB2_Schema : how to specify auto_increment ? (and other questions) | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-21171@lists.php.net to get a copy of this message | ||
I try to use MDB2_Schema for alter, create and generate schema files. But there is no end user
documentation so I try to ask my questions here.
The dump operation succeed. I try with :
'portability' => (MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL)
and
'portability' => (MDB2_PORTABILITY_ALL )
But when I try to reload the xml file, I encounter several problems :
- the fields with auto_increment property lost this property. How can I keep auto_increment property
?
- In my database, I had 'not null' fields but no default value. The generated files
describe :
in the first case
<field>
<name>idh</name>
<type>integer</type>
</field>
in the second case
<field>
<name>idh</name>
<type>integer</type>
<notnull>1</notnull>
</field>
In the first case I lost "not null" properties. In the second case I can't reload
with MDB2_schema, the message is :
[userinfo] => Parser error: if field is "notnull", it needs a default value - No
error - Byte: 198; Line: 17; Col: 100
If I use :
<default></default> (for empty)
I get another errors :
[userinfo] => [Last query: CREATE TABLE histo (idh INT DEFAULT NULL NOT NULL,dateCol DATETIME
DEFAULT '0000-00-00 00:00:00',nom CHAR (50) DEFAULT NULL NOT NULL,type CHAR (1) DEFAULT
'D' NOT NULL,result CHAR (1) DEFAULT 'D' NOT NULL,perte INT DEFAULT 0 NOT NULL)]
[Native code: 1067]
[Native message: Valeur par défaut invalide pour 'idh']
You can note the DEFAULT NULL NOT NULL that cause the problem.
In conclusion, I don't know how to generate a correct schema files.
Any idea ?