Re: M. Lemos's form class questions

From: Date: Mon, 30 Oct 2000 02:37:08 +0000
Subject: Re: M. Lemos's form class questions
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-4027@lists.php.net to get a copy of this message
Hello Jouni, On 29-Oct-00 15:22:33, you wrote: >> It is easy to figure if a query is CREATE DATABASE or DROP DATABASE and so >> not prepare it. >I have to disagree... and after looking at the sources of isql, I found >out that even those people who wrote InterBase couldn't do it. They had to >write quite a complex parser to handle all the cases where they can't just >pass the statement to isc_dsql_prepare(). I'm not sure what you mean, but I thought it would do a simple: strcmp(substr(strtoupper($query),0,strlen("CREATE DATABASE")),"CREATE DATABASE") >> >For the needs of MetaBase, I think the easiest solution will be to create >> >functions ibase_create_database(), ibase_drop_database and maybe >> >ibase_do() that calls isc_dsql_execute_immediate() (if there appears to >> >be more SQL statements that have problems with the way the module >> >currently works. You know any?). >> >> >Would this be a sufficient solution? At least it would be the easiest one. >> >> CREATE DATABASE requires any type of connection to the server but DROP >> DATABASE requires you to connect the actual DATABASE you will be dropping. >> If you can make it work that simple with a couple of functions, it's fine >> for me. >> >> I am just not sure about the right sequence of statements that will be used >> from PHP code because if those functions establish the connection to the >> server they need to get also a bunch of connection parameters. If they >> take a connection handle parameter instead that handle has to be set to >> connect to the database to be dropped. >Creating a database actually doesn't need any kind of opened connection. >Both the database handle and transaction handle must be NULLs when using >isc_dsql_execute_immediate() and the statement is CREATE DATABASE. After >reading the documentation of MetaBase, I think this will play quite nicely >together with MetabaseSetupDatabase() and MetabaseCreateDatabase(). Yes, if all you need a is full (or relative) database connection spec (with host address, database file path, etc...) it can be passed like to ibase_connect since Metabase does not need to keep the database connection handle for anything when it creates or drops a database. >Unfortunately, I guess I can't say the same about DROP DATABASE. >ibase_drop_database() will be written so that it needs a connection >handle. I haven't yet looked at the internals of MetaBase, but my hunch is >that it could be a bit more tricky. At the minimum, there would be the >need to keep the names of currently opened InterBase database files >around, compare them to the name given to MetabaseDropDatabase() and >temporarily open it if there's no match, passing the right handle if >found. MetabaseDropDatabase only takes the database name. The database directory path, the database file extension, the host address, etc... are passed to MetabaseSetupDatabase. >Of course, I could have totally misunderstood how MetaBase works... :( But >at least I really bothered to read the documentation and some sources to >understand your needs :) Thank you for trying, it's more than I could ask. :-) Regards, Manuel Lemos Web Programming Components using PHP Classes. Look at: http://phpclasses.UpperDesign.com/?user=mlemos@acm.org -- E-mail: mlemos@acm.org URL: http://www.mlemos.e-na.net/ PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp --

« previous php.db (#4027) next »