Re: MySQL depreciated mysql_list_* commands: Replacements?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 10 Sep 2003, Micah Stevens wrote:

> describe TBL;
> explain TBL;
> show columns from TBL;

 Yes, they do give the correct information.

 However, my question was is there a nice simple SQL command that will
 return exactly what mysql_list_fields (now depreciated) so that the
 $result can be used with the mysql_field_* functions.

 All of the above commands give the exact same data in the same format, all
 of which are incompatible with the mysql_field_* functions.

 $fld_results     = mysql_query("show fields from ".$db.".".$tbl) or die(mysql_error().'PMA_mysql_list_fields(' . $db . ', ' . $tbl . ')');
 $fld_results_cnt = ($fld_results) ? mysql_num_fields($fld_results) : 0;
 for ($j = 0; $j < $fld_results_cnt; $j++) {
    echo mysql_field_name($fld_results, $j) . "<br/>";
 }

 Returns:

  Field
  Type
  Null
  Key
  Default
  Extra

 instead of what I was expecting.

> On Wed September 10 2003 12:08 pm, Peter Beckman wrote:
> > So PHP is saying mysql_list_tables is depreciated.  I replaced it with
> > mysql_query("SHOW TABLES FROM DB") and everything is fine.
> >
> > Then mysql_list_fields didn't work right.  So I submitted a bug
> > (http://bugs.php.net/bug.php?id=25460) about it, and they said IT TOO was
> > depreciated, which is fine.  But I haven't figured out how to replace
> > mysql_list_fields with a nice simple SQL command, since a bunch of code
> > relies on mysql_list_fields to return a nice $result (ie Resource #37) to
> > use with mysql_field_flags, mysql_field_name, etc.
> >
> > Anyone got any ideas on how to do that without replacing mysql_field_flags
> > et al?  Or do I have to rewrite the code entirely to use "SHOW FIELDS FROM
> > DB.TABLE" and rewrite my own _field_ functions?

---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux