PHP will handle your var types for you just fine. If
you want to bet sure, so an intval() before you
compare.

On Fri, 4 Jan 2002 16:18:24 -0500, Erik Price used a
few recycled electrons to form:

| There's no data in the database yet, so I haven't tested this code.  I 
| don't want to use the mysql CLI client to input data b/c the data is 
| spread out over a number of tables, rather, I'm writing PHP pages that 
| provide a means to populate the database in an organized way.  But until 
| the PHP is done, I can't test... conundrum?
| 
| Erik
| 
| 
| On Friday, January 4, 2002, at 03:07  PM, Rick Emery wrote:
| 
| > What happened when you experimented?  What were your results?
| >
| > -----Original Message-----
| > From: Erik Price [mailto:[EMAIL PROTECTED]]
| > Sent: Friday, January 04, 2002 2:03 PM
| > To: [EMAIL PROTECTED]
| > Subject: ENUM -- integers or strings?
| >
| >
| > 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 <mysql-unsubscribe-
| > [EMAIL PROTECTED]>
| > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
| >
| > ---------------------------------------------------------------------
| > 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 <mysql-unsubscribe-
| > [EMAIL PROTECTED]>
| > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
| >
| 
| 
| ---------------------------------------------------------------------
| 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
| 


---------------------------------------------------------------------
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