A quick question --

If I have a table with an ENUM column, and the possible values are ("0", 
"1", "2", "3"), does the number qualify as an integer or a string?

I am working in PHP4 and intend to compare this value as such:

// dbaccess.access_level is ENUM("0", "1", "2", "3") column
// $user_id has been established already

<?php
// get the access level for the user based on their ID
$sql = "        SELECT dbaccess.access_level
                FROM dbaccess, users
                WHERE $user_id = users.user_id
                AND users.dbaccess_id = dbaccess.dbaccess_id " ;
$result = mysql_query($sql, $db) ;
$access_level = $result ;

// generate page content according to the user's access level
switch ($access_level) {
        case $access_level > 2 :
                // generate HTML + PHP page giving user
                // ability to SELECT, INSERT, UPDATE, or
                // DELETE from tables.  Finish page, then
                break ;
        case $access_level > 1 :
                // generate HTML + PHP page giving user
                // ability to SELECT or INSERT from/to
                // tables.  Finish page, then
                break ;
        case $access_level > 0 :
                // generate HTML + PHP page giving user
                // ability to SELECT from tables.
                // Finish page, then
                break ;
        default :
                // print "You cannot access this
                // information." Finish page.
} ;

Sure, the question is really quick (whether or not ENUM returns an 
integer or string), but now that I think about it, does it really matter 
for the purposes of my example here?  Wouldn't this PHP code be able to 
take a string or an integer as an argument to the "switch" statement?

Thanks for any advice anyone can give!


Erik


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to