#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    1
    Rep Power
    0

    mysql_result() --> to postgreSQL?


    Hey there guys,

    I'm migrating a set of PHPs from MySQL to postgreSQL. However, I still haven't found the answer to my question: what's the equivalent of the mysql_result() command in postgreSQL?

    For example:

    in MySQL:
    mysql_result($aeropuertos,$x,'id_dept'),$conn)

    How should I rewrite that for postgreSQL?

    Thanks a lot.
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    RTF PHP M!

    pg_fetch_result(resource result, int row, mixed field)
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    373
    Rep Power
    11
    there are many different ways also

    I like the fetch_array the best. Depends on whay you're doing, and also which version of php you're going to use
  6. #4
  7. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    Originally posted by metaBarf
    there are many different ways also

    I like the fetch_array the best. Depends on whay you're doing, and also which version of php you're going to use
    Yes, but fetching a scalar result is a logically different operation from these other functions you link to.

    Specifically, mysql_result and pg_fetch_result allow you to simply "get" one value from a query without messing around with loops or arrays--nice for one-liners like:

    PHP Code:
    $sales_total pg_fetch_result(pg_query($conn"SELECT SUM(amount) FROM sales_history"),0,0); 
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com

IMN logo majestic logo threadwatch logo seochat tools logo