Re: [pLog-General] Problems, anyone?
Brought to you by:
jondaley
From: Oscar R. <os...@re...> - 2004-03-03 07:19:13
|
No, I had never heard of this functionality before... Looks like ADOdb is a great package that we are underusing :) I'll have a look at this for the next development cycle. Oscar > On Mar 2, 2004, at 1:10 PM, Oscar Renalias wrote: > >> there have been changes in the db schema and that an update is needed. >> We'll have to think of something for the next development cycle > > Have you looked at ADOdb's ability to automatically check the schema > and add or alter as needed? See > http://phplens.com/lens/adodb/docs-datadict.htm. > > Maybe you could check and update the schema if needed each time there's > a login by the admin. > > I'm using code in a plugin that looks like this: > function init_database() { > // Get the config values > $config =3D new Config(); > $dbPrefix =3D $config->getValue( "db_prefix" ); > $table =3D $dbPrefix.'_scores'; > // for background, see > http://phplens.com/lens/adodb/docs-datadict.htm > $fields =3D " > blog_id I(10) NOTNULL, > article_id I(10) NOTNULL, > score I(5) NOTNULL > "; > // create a data dictionary object > $newdb =3D &ADONewConnection('mysql'); > $newdb->Connect( $host, $user, $password, $database ); > $dict =3D NewDataDictionary($newdb); > // Checks to see if table exists, if table does not exist, > // adds the table. If table exists, generates appropriate > // ALTER TABLE MODIFY COLUMN commands if field already exists, > // or ALTER TABLE ADD $column if field does not exist. > $sqlarray =3D $dict->ChangeTableSQL($table, $fields); > $dict->ExecuteSQLArray($sqlarray); > $this->configMessage =3D 'Created new data table '.$table.'.'; > return true; > } > > > -- > Daniel > ke...@fo... > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id438&op=CCk > _______________________________________________ > pLog-General mailing list > pLo...@li... > https://lists.sourceforge.net/lists/listinfo/plog-general |