SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Nov 2002
    Location
    Maryland
    Posts
    307
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Convert PostgreSQL DB function to Mysql

    Hello,
    I need to convert the following PostgreSQL DB connection function to MySQL.

    PHP Code:
      public function query($sql$code_return_mode 0) {
        
    $q_handle pg_exec($this->link_ident$sql);
        
        for (
    $i=0$i<=pg_numrows($q_handle)-1$i++) {
          
    $result pg_fetch_array($q_handle,$i);  
          
    $return_array[$i] = $result;
        };
        if (!
    $q_handle) {
          
    error_log("QUERY FAILED: $sql\n");
        };
        
    $this->result_rows $return_array;
        if (!
    $q_handle) {
          return(
    1);
        } else {
          return(
    0);  # return 0 if it fails
        
    };
      } 
    Does anyone know the MySQL equivalents for the PostgreSQL php functions used in the function?

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    try
    PHP Code:
    public function query($sql$code_return_mode 0) {
        
    $q_handle mysql_query($this->link_ident$sql);
        
        for (
    $i=0$i<=mysql_num_rows($q_handle)-1$i++) {
          
    $result mysql_fetch_array($q_handle,$i);  
          
    $return_array[$i] = $result;
        };
        if (!
    $q_handle) {
          
    error_log("QUERY FAILED: $sql\n");
        };
        
    $this->result_rows $return_array;
        if (!
    $q_handle) {
          return(
    1);
        } else {
          return(
    0);  # return 0 if it fails
        
    };
      } 
    Spike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •