上次蒙各位大神耐心解答,把DB部分搞定了。
现在要改php里面的数据库函数,但是用到了一个pg_fetch_result函数好像mysql里面没有相对应的函数。
这个函数貌似用于取得结果集指定行,指定列的值,现在要用mysql相应的函数应该怎么做?
pg_fetch_result
(PHP 4 >= 4.2.0, PHP 5)pg_fetch_result -- 从结果资源中返回值
说明
mixed pg_fetch_result ( resource result, int row, mixed field )
pg_fetch_result() 根据由 pg_query() 返回的 result 资源返回相应的值。row 为整型数。field 为字段名(字符串)或字段索引(整数)。row 和 field 指明了查询结果中的哪个单元被返回。行编号从 0 开始。除了用字段名之外,还可以用不带引号的数字作为字段索引。字段索引从 0 开始。
 

解决方案 »

  1.   

    没有研究pg_fetch_resultPHP的处理记录的例子如下<?php
    $result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
    if (!$result) {
        echo 'Could not run query: ' . mysql_error();
        exit;
    }
    /* Use the result, assuming we're done with it afterwards */
    $row = mysql_fetch_assoc($result);/* Now we free up the result and continue on with our script */
    mysql_free_result($result);echo $row['id'];
    echo $row['email'];
    ?>
      

  2.   


    调用 mysql_result() 不能和其它处理结果集的函数混合调用。 例子 1. mysql_result() 例子<?php
       $link = mysql_connect("localhost", "mysql_user", "mysql_password")
               or die("Could not connect: " . mysql_error());   $result = mysql_query("SELECT name FROM work.employee")
               or die("Could not query: . mysql_error());   echo mysql_result($result,2); // outputs third employee's name   mysql_close($link);
    ?>  
     
    推荐使用高性能的替代函数:mysql_fetch_row(),mysql_fetch_array(),mysql_fetch_assoc() 和 mysql_fetch_object()。 
    自己找到了,呵呵。
    但是好像不推荐使用的样子。
      

  3.   

    散分散分,ACMAIN_CHM大神分已经很多了。
    下班前或者明天早上结贴。
      

  4.   

    我建议你可以用PDO,操作性能比原来的mysql函数高很多的