et) : false;
}
function sql_fetchrow($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
if($query_id)
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]);
if( $this->row )
{
$this->rownum[$query_id]++;
return $this->row;
}
}
return false;
}
function sql_fetchrowset($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
if( $query_id )
{
unset($this->rowset[$query_id]);
unset($this->row[$query_id]);
$this->rownum[$query_id] = 0;
while( $this->rowset = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC) )
{
$result[] = $this->rowset;
$this->rownum[$query_id]++;
}
return $result;
}
return false;
}
function sql_fetchfield($field, $row_offset=-1, $query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
if( $query_id )
{
if( $row_offset != -1 )
{
$this->row = @pg_fetch_array($query_id, $row_offset, PGSQL_ASSOC);
}
else
{
if( $this->rownum[$query_id] )
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id]-1, PGSQL_ASSOC);
}
else
{
$this->row = @pg_fetch_array($query_id, $this->rownum[$query_id], PGSQL_ASSOC);
if( $this->row )
{
$this->rownum[$query_id]++;
}
}
}
return $this->row[$field];
}
return false;
}
function sql_rowseek($offset, $query_id = 0)
{
if(!$query_id)
{
$query_id = $this->query_result;
}
if( $query_id )
{
if( $offset > -1 )
{
$this->rownum[$query_id] = $offset;
return true;
}
else
{
return false;
}
}
return false;
}
function sql_nextid()
{
$query_id = $this->query_result;
if($query_id && $this->last_query_text[$query_id] != "")
{
if( preg_match("/^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)/is", $this->last_query_text[$query_id], $tablename) )
{
$query = "SELECT currval('" . $tablename[1] . "_id_seq') AS last_value";
$temp_q_id = @pg_exec($this->db_connect_id, $query);
if( !$temp_q_id )
{
return false;
}
$temp_result = @pg_fetch_array($temp_q_id, 0, PGSQL_ASSOC);
return ( $temp_result ) ? $temp_result['last_value'] : false;
}
}
return false;
}
function sql_affectedrows($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
return ( $query_id ) ? @pg_cmdtuples($query_id) : false;
}
function sql_freeresult($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
return ( $query_id ) ? @pg_freeresult($query_id) : false;
}
function sql_error($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
$result['message'] = @pg_errormessage($this->db_connect_id);
$result['code'] = -1;
return $result;
}
} // class ... db_sql
} // if ... defined
?>