[nycphp-talk] Creating database tables when deploying products
Ben Sgro (ProjectSkyline)
ben at projectskyline.com
Sat Mar 31 23:34:10 EDT 2007
Hello Paul,
Excellent points. I'm *shamed* .. as stated, "less painful", heh.
I believe Jiju had mentioned using .sql files as well, its a great idea.
I may try that out on my next project.
Up until taking a recent job, our shop only supported mySQL. That's where
all my experiance lies (besides a few months at a MSSQL shop).
But now we need to support MSSQL, and I just ported my SQL
php 4 libs to OOP PHP 5....(guess I'll write these libs right the first
time).
I suppose I can use PEAR:DB:SQLwhatever, but I'm intimate
what my SQL code and don't want to give it up.
Anyways, thanks again to all!
- Ben
----- Original Message -----
From: "Paul Houle" <paul at devonianfarm.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Saturday, March 31, 2007 10:05 PM
Subject: Re: [nycphp-talk] Creating database tables when deploying products
> Ben Sgro (ProjectSkyline) wrote:
>>
>> $sqlStr = "CREATE TABLE admin "
>> . " (id int(11) NOT NULL auto_increment,"
>> . " username varchar(64) default '',"
>> . " password varchar(64) default '',"
>> . " last_login int(12) default 0,"
>> . " primary key(id, username)"
>> . ')';
>> DBAS_MySQLQuery($sqlStr, $db);
> Not too bad, but PHP isn't Java. you can write multi-line string
> literals.
>
> $sqlStr = "
> CREATE TABLE admin (id int(11) NOT NULL auto_increment,
> username varchar(64) default,
> password varchar(64) default ','
> last_login int(12) default 0,
> primary key(id, username)
> )";
>
> More readable, less painful. I'm thinking about this stuff too.
> There are lots of people who are addicted to visual tools like the
> "Enterprise Manager" that comes with Microsoft SQL Server. These have
> their place, but you really should be writing DDL (CREATE TABLE, etc.) if
> you want consistent results. Historically, I've written schema files
> into *.sql files that can be
>
> * cut and pasted into the MS-SQL "Query Analyser", or
> * mysql -uuser -p db_name < load_schema.sql
>
> The cross database thing is making me think about a different answer.
> Also lately I've been creating large numbers of repetitive tables, or
> groups of tables that all have certain columns (timestamps, for instance)
>
> When it comes to cross database, however, you ought to think about
> the business goal you're after. It's pretty silly to support all 20 or so
> relational databases that PHP can connect to. Most organizations,
> however, will have a few databases that are reasonable targets:
>
> * Mysql and MS-SQL: the kind of shop that likes to have it both ways with
> Microsoft and Open Source. You can ship apps that will keep most people
> happy.
> * Mysql and Oracle: good for the Unix shop which has both entrepreneurial
> projects (install Linux, start coding) and 'enterprise' systems (ask your
> boss to ask her boss to ask his boss to ask the DBA to make you a table)
> * Postgresql and MySQL: if you want to please all the open source people
> you meet
>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
More information about the talk
mailing list