Re: Database Preference? -- Manuel, Michael, Miles

From: Date: Thu, 30 Aug 2001 22:00:59 +0000
Subject: Re: Database Preference? -- Manuel, Michael, Miles
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-65382@lists.php.net to get a copy of this message
Manuel, Thanx for the excellent overview of metabase. I will give it a test drive. A couple further questions, if you have time: Do you execute meta commands like you do with the other db interface functions, e.g., odbc_connect(), odbc_select(), etc., or are you able to encapsulate SQL between tags, e.g. <tag> SELECT bar FROM foo WHERE barname = "chocolate"; </tag> Using a function set can be cumbersome, compared to embedded language interfaces where you just put SQL between tags, just like PHP is handled between the <? ?> tags. Also, can you PREPARE, DECLARE, and OPEN cursors like, say, in Informix, so you can use variable SELECT parameters? For example, using Informix ESQL/C you can PREPARE a statement, use it to DECLARE a CURSOR, and the OPEN the CURSOR USING multiple values, as in: sprintf( query, "%s %s %s %s %s %s %s %s %s", "begin work;", "update account set balance = balance + ?," "where acct_number = ?;", "update teller set balance = balance + ?", "where teller_number = ?;", "update brance set balance = balance + ?", "where branch_number = ?;" "insert into history values (?, ?);", "commit work;" ); $prepare qid from $query; $execute qid using $delta, $acct_number, $delta, $teller_number, $delta, $branch_number, $timestamp, $values; I should be able to check metabase out later this evening. If it can handle the above native database language, I think it will be an asset, especially for some of our older applications. Thanx again, James Potts "Manuel Lemos" <mlemos@acm.org> wrote in message news:3B8E8E47.289283CD@acm.org... > Hello, > > James wrote: > > Regarding a database abstraction package: does Metabase handle all > > "standard" SQL constructs (as opposed to vendor-specific SQL extensions)? > > The GUI applications to be ported were built with JAM, which basically > > provides an abstraction layer via its JPL language. JPL has not been > > restrictive in terms of required functionality, nor was there any real > > performance hits. Can the same be said of Metabase? Also, would Metabase > > present a significant learning curve for experienced C and SQL programmers? > > > > I will download PostgreSQL and check it out. > > Metabase does much more than you probably may want. Basically you can > just submit any queries to the database server. Metabase doesn't touch > them. What it does is when you are composing your queries with constant > values, it may convert the respective data type values from a database > independent data type set to the target database data types. > > Let's say you have strings or date constant values. Each database may > have different ways to escape strings or format dates. Metabase provides > functions to do that translation if you want to use direct queries. I > you want to use prefered queries, with placeholders ( ? ) in the queries > that are replace with constant values when the queries are executed, the > functions to set those values perform the translations for you. > > For retrieving result data returned by SELECT queries, Metabase also > provides functions to translate the data to a database independent > format, so in your applications you only have to handle one universal > format that you do not need to adapt if you decide to switch to your > database backend. > > That is not all. Metabase also provides unique features, that are very > important for Web programming, all in a database independent way. One is > the ability to create and access to database sequence objects. Sequences > are objects that can generate sequential integer unique numbers. They > are often used to generate id values for table primary keys. Sequence > number generation is guaranteed to be atomic, so it is adequate for > environments where many users access the database concurrently, like the > Web. Sequences are implemented with real sequence objects in databases > that support it like Oracle and Postgres, but others that don't support > real sequence objects are emulated with tables with a single > auto-incremented integer field. > > Another important feature is the ability for Web programming is the > ability to limit the range of rows that are returned from a select > query, like MySQL LIMIT clause, but in a way that is supported by all > databases supported by Metabase. This is great to let you develop > applications that display query results split in multiple pages if they > have too many rows. > > Metabase is not also good for develop applications to access databases. > It is also able to install databases for you creating tables, fields, > indexes and sequence from a database independent schema description > defined in a specific XML format. Also, if later you need to change your > database schema, all you need to do is change the schema description XML > file. Metabase manager is able to figure the differences between the new > and the previously installed schema and then it just alters the database > without affecting the data that was stored after the database was > installed for the first time or changed for the last time. This saves > you toons of hours and maintenance headache. > > Metabase is easy to learn. In the site there is a tutorial document that > get you started real quick. If you need further help, you may join to > the Metabase development mailing list that is listed in the Metabase > page links sections. Look also in the database section of the PHP > Classes site for components ready to use with Metabase. > > Regards, > Manuel Lemos

« previous php.general (#65382) next »