Hello,

"Martin E. Koss" wrote:
> 
> While I appreciate your comments about metabase I simply don't have time to
> start the project again, it has taken a long time to get this far. Perhaps
> I'll look at metabase for future developments.
> 
> In the meantime, anyone seeing this message for the first time, I'm still
> struggling with my code below:

Your mistake is very basic. If you read my message again, you can see
that I am telling you that you are forgetting to declare the type of the
column that you want to add.

My suggestion to use Metabase is that it helps you to maintain database
schemas without having to struggle with the way that the database wants
you to declare the changes you want to be done. If you are having
difficulty to understand how it needs to be done now, chances are that
you will still have difficulty to figure how to make these and other
types of database schema changes in the future. If switching to Metabase
would be a good idea to avoid your difficulties, it is up to you to
figure.

Manuel Lemos

> 
> Martin.
> 
> -----Original Message-----
> From: Manuel Lemos [mailto:[EMAIL PROTECTED]]
> Sent: 29 March 2001 14:05
> To: [EMAIL PROTECTED]; Martin E. Koss
> Subject: Re: [PHP-DB] ALTER TABLE - code not working.
> 
> Hello,
> 
> "Martin E. Koss" wrote:
> >
> > I have been trying to get a new column added to a table (vips) via a PHP
> > script, but having exhausted all the things I can find, I'm still
> > struggling. I've referred t TFM for all those who just can't wait to tell
> me
> > to do so, and believe my SQL statement is correct:
> >
> $NewCol = $Prod_Code;
> $defaultvalue = "0.00";
> // make usual connection
> $conID = mysql_pconnect ("localhost","myusername","mypassword");
> mysql_select_db("FocusDynamics", $conID);
> // set the query
> $AddColQuery = "ALTER TABLE vips ADD COLUMN $NewCol";
> $result = mysql_query ($AddColQuery,$conID);
> // now set the default value for all rows in vips table
> $SetDefault = "UPDATE TABLE vips SET $NewCol=$defaultvalue";
> $result = mysql_query ($SetDefault,$conID);
> 
> It is NOT adding the column, and obviously not setting the default.
> 
> I presume that the $Prod_Code is just the name of the field.
> YES! You assume right.
> Martin.
> 
> You also
> need to declare the type of the field. BTW, if you declare the default
> value too in the ALTER TABLE statement the existing rows will be filled
> with that value in that column.
> 
> You may want to look at Metabase which is a PHP database abstraction
> package that is able to install and maintain database schema giving just
> a schema description file defined in a specific XML format. Metabase is
> able to parse the schema definitions and install any tables, fields,
> indexes and sequences described in the schema definition.
> 
> When you want to change anything in your schema (adding, removing,
> altering tables, fields, indexes and sequences) Metabase manager will
> figure the changes you made in the schema definition and apply them to
> the installed database without disturbing any data already inserted
> after the first time the schema was installed or it was changed for the
> last time. No sweat, no risk mistake. Look at Metabase here:
> 
> http://phpclasses.UpperDesign.com/browse.html/package/20
> 
> Manuel Lemos
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to