NYCPHP Meetup

NYPHP.org

[nycphp-talk] newbie confusion

Christopher Hendry chendry at gmail.com
Wed Nov 10 23:30:18 EST 2004


> 
> I'm googling for the tutorial(s) or examples I need but I'm not finding
> yet...
> 

Well, it pretty much sounds like you're off to a good start.  Breaking
down the application flow, abstracting where you can, etc.  But I'm
not quite sure where your question is.

I'd recommend putting the same kind of thought to the places where you
are 'lost' - ie, if you're wondering how to put new interviewers into
the DB that don't exist, break it down step by step and write some
functions to handle it.  Otherwise www.php.net/mysql_insert_id will
probably be handy.

function add_new_interviewer( &$interveiwer_info ) {

    $query = "INSERT...";
    $result = mysql_query($query) or error_handler();
    $new_key = mysql_insert_id();  // yes, yes - need better error
handling, what if the insert fails?

  return $new_key;

}

if (!$pulldown) $new_interviewer_ID = add_new_interviewer( $some_form_data );

I would say you're pretty safe with gender being an enum - unless
we're looking to add some new genders some time soon.  Interested? 
Well, if you're certain that you'll never use anything besides yes or
no than an enum could work, as could a tiny int for true/false.  Kinda
depends on your app.  But why add an extra query or join when they
will not change and can be coded into your app (or config file).

Overall remember that applications evolve and do your best to allow
for that in your initial design.  You'll never get it perfect and
pieces will have to be rewritten - but it seems to me that you're
doing just fine.

:)

C

-- 

"When you do things right, people won't be sure you've done anything at all."



More information about the talk mailing list