Ben Sgro (ProjectSkyLine) wrote:
Hello all,
#1 Thanks for the ideas on CSS (my last question). I still haven't been able to invest the type of time I would like to play around with the code, but I will. I got the CSS Mastery book and I've got an APress
book on HTML/CSS design patterns. Both look promising.
I started off doing db deployment code in a seperate file, say createdb.php that I would run from
the URL.
include ('PROS.php');
    include ('../LIBRARY/DBAS.php');
DBAS_InitDBHandle(PROS_SQLInfo( ), 'PROS.php', $db);
    DBAS_MySQLUseDB(constPROSDBStr, $db);
$tableSet = DBAS_FetchTables(constPROSDBStr, $db);
    if ( @ !$tableSet[constContentStr])
    {
        error_log("createdb.php: creating 'content' table");
        $sqlStr = "CREATE TABLE content "
                . "(id int(11) NOT NULL auto_increment,"
                . " display_on    int(11) default 0,"

<snip>

After a while, that was kinda of a pain and I moved to something internal to the index.php?action=create_database file
and cleaned up my database object code.
/* Comments table. */
        $dbObject->DatabaseCreateTable(DATABASE_TABLE_COMMENTS);
$dbObject->DatabaseCreateField('comment_id', 'int(11)', 'NOT NULL',
                                       'auto_increment');

<snip>

Which I used for a while and I liked it. Except its a lot to type for larger databases.
So I started messing with YAML and I've got my code down to this:
emails:
    id:
        type:    int(11)
        default: not null
        extra:   auto_increment
    email:
        type:    varchar(255)
        default: default 0
        extra:

<snip>

Which I just feed into a method that creates the table. I have this code only execute when I pass a command line switch in, say php index.php -f db.yaml. If I don't have
CL access then I'd have to move it to the URL.
Do you all think agree this is a better direction ?

It's the only way to fly!

The next enhancement would be conditional building. Before the system builds a table, have it examine the server to see if the table exists, and then it should be smart enough to only add columns that need to be added. From there you get into more complex issues like changes to column widths, changes to column types. Then there are backfills....

In Andromeda this entire process is handled by "AndroBuild.php", which runs down the entire process, plus lots of other security and automation-related stuff.

What are some pitfalls I could run into
doing db's this way?

None. Every computer program in the universe is meant to be moved from machine to machine. When you move a database app you've got to have a mechanism to ensure the structures are correct.

IMHO it is the lack of these types of tools that is the main reason many people try to avoid getting rigorous with their database structures -- without the right tools it's just too much work and too error prone.

Thanks so much! - Ben Ben Sgro, President
ProjectSkyLine - Defining New Horizons
+1 718.487.9368 (N.Y. Office)
Our company: www.projectskyline.com <http://www.projectskyline.com>
Our products: www.project-contact.com <http://www.project-contact.com>
This e-mail is confidential information intended only for the use of the individual to whom it is addressed.
------------------------------------------------------------------------

_______________________________________________
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


--
Kenneth Downs
Secure Data Software, Inc.
www.secdat.com    www.andromeda-project.org
631-689-7200   Fax: 631-689-0527
cell: 631-379-0010

_______________________________________________
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

Reply via email to