RE: [PHP] How to get each value out of set function?

From: Date: Thu, 26 Oct 2000 02:35:11 +0000
Subject: RE: [PHP] How to get each value out of set function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-22015@lists.php.net to get a copy of this message
Hi Calvin, > I am trying to get the value one by one from the set funtion inside > table_priv column of mysql.tables_priv table. I need to know whether the > user has the select or insert or delete privileges on the certain > table, so > I could have different design display based on different privileges. For > example, if the table A for user 111 (ignore the host the db fields) has > select, insert and update privileges on the table_priv column of > mysql.tables_priv table, how could I find out the insert > privileges is true > on the field? Could anyone help, please? Thanks a lot. df_id|df_setfieldtype -----+--------------- 1|S,I,U 2|S 3|S,I,U,D S = SELECT_PRIV I = INSERT_PRIV U = UPDATE_PRIV D = DELETE_PRIV PHP3: <? // snip $dbh = mysql_query("SELECT df_setfieldtype FROM table WHERE df_id = 2"); $rs = mysql_fetch_array($dbh); $value_array = explode(',',$rs['df_setfieldtype']); $insert_priv = false; while(list(,$value) = each($value_array) { if($value == 'I') { $insert_priv = true; } } if ($insert_priv) print 'Can insert'; // snap ?> PHP4: <? // snip $dbh = mysql_query("SELECT df_setfieldtype FROM table WHERE df_id = 2"); $rs = mysql_fetch_array($dbh); $value_array = explode(',',$rs['df_setfieldtype']); if (in_array('I',$value_array) print 'Can insert'; // snap ?> Hope this helps, Matthias

« previous php.general (#22015) next »