function _insertid($table, $column)
 {
     if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') {
         return false;
     }
     $oid = pg_getlastoid($this->_resultid);
     // to really return the id, we need the table and column-name, else we can only return the oid != id
     return empty($table) || empty($column) ? $oid : $this->GetOne("select {$column} FROM {$table} WHERE oid=" . (int) $oid);
 }
Exemple #2
0
 function _insertid()
 {
     return pg_getlastoid($this->_resultid);
 }
 function _insertid()
 {
     if (!is_resource($this->_resultid)) {
         return false;
     }
     return pg_getlastoid($this->_resultid);
 }
Exemple #4
0
 function getInsertID()
 {
     return pg_getlastoid($this->result[$this->stack_last]);
 }
 function _insertid()
 {
     if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') {
         return false;
     }
     return pg_getlastoid($this->_resultid);
 }
function db_last_oid()
{
    global $sys_dbhost, $sys_dbuser, $sys_dbpasswd, $sys_dbname, $db_debug, $conn, $conn_update, $QUERY_COUNT;
    global $DBSERVER, $OWNER, $PW, $DB;
    return pg_getlastoid($conn);
}
/**
 *
 *  Returns the last primary key from an insert
 *
 *  @param qhandle query result set handle
 *  @param table_name is the name of the table you inserted into
 *  @param pkey_field_name is the field name of the primary key
 *
 */
function db_insertid($qhandle, $table_name, $pkey_field_name)
{
    $oid = @pg_getlastoid($qhandle);
    if ($oid) {
        $sql = "SELECT {$pkey_field_name} AS id FROM {$table_name} WHERE oid='{$oid}'";
        //echo $sql;
        $res = db_query($sql);
        if (db_numrows($res) > 0) {
            return db_result($res, 0, 'id');
        } else {
            //	echo "No Rows Matched";
            //	echo db_error();
            return 0;
        }
    } else {
        //		echo "No OID";
        //		echo db_error();
        return 0;
    }
}
 function get_last_insert_id($table, $field)
 {
     if (!isset($table) || $table == '' || !isset($field) || $field == '') {
         return -1;
     }
     $oid = pg_getlastoid($this->Query_ID);
     if ($oid == -1) {
         return -1;
     }
     $result = @pg_Exec($this->Link_ID, "select {$field} from {$table} where oid={$oid}");
     if (!$result) {
         return -1;
     }
     $Record = @pg_fetch_array($result, 0);
     @pg_freeresult($result);
     if (!is_array($Record)) {
         return -1;
     }
     return $Record[0];
 }
	function _insertid($table,$column)
	{
		if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false;
		$oid = pg_getlastoid($this->_resultid);
		// to really return the id, we need the table and column-name, else we can only return the oid != id
		return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table ORDER BY $column DESC LIMIT 1");
	}
Exemple #10
0
<?php

include 'config.inc';
$db = pg_connect($conn_str);
$result = pg_exec("SELECT * FROM " . $table_name);
pg_numrows($result);
pg_numfields($result);
pg_fieldname($result, 0);
pg_fieldsize($result, 0);
pg_fieldtype($result, 0);
pg_fieldprtlen($result, 0);
pg_fieldisnull($result, 0);
pg_result($result, 0, 0);
$result = pg_exec("INSERT INTO " . $table_name . " VALUES (7777, 'KKK')");
$oid = pg_getlastoid($result);
pg_freeresult($result);
pg_errormessage();
$result = pg_exec("UPDATE " . $table_name . " SET str = 'QQQ' WHERE str like 'RGD';");
pg_cmdtuples($result);
echo "OK";
Exemple #11
0
 /**
  * Return the last insert ID
  * @return integer
  */
 protected function insert_id()
 {
     return @pg_getlastoid($this->resResult);
 }
 function Add_table($value, $func_fields = null, $func_table = null, $id_name = null)
 {
     //global $link;
     global $DBHandle;
     if ($func_fields != "") {
         $this->fields = $func_fields;
     }
     if ($func_table != "") {
         $this->table = $func_table;
     }
     $QUERY = "INSERT INTO \"" . $this->table . "\" (" . $this->fields . ") values (" . trim($value) . ")";
     if ($this->debug_st) {
         echo "<br>QUERY:" . $QUERY;
     }
     if (!($res = $DBHandle->query($QUERY))) {
         //if (! $res=DbExec($link, $QUERY)) {
         //$this -> errstr = "Could not create a new instance in the table '".$this -> table."'";
         $this->errstr = $DBHandle->Error;
         return false;
     }
     if ($id_name != "") {
         $oid = pg_getlastoid($res);
         if ($oid < 0) {
             return false;
         }
         $sql = 'SELECT "' . $id_name . '" FROM "' . $this->table . '" WHERE oid=\'' . $oid . '\'';
         if (!($res = $DBHandle->query($sql))) {
             return false;
         }
         $DBHandle->next_record();
         $row[] = $DBHandle->Record;
         return $row[0][0];
     }
     return true;
 }
 /**
  * Find the primary key of the last insertion on the current db connection
  *
  * @param string $table name of table the insert was performed on
  * @param string $field the autoincrement primary key of the table
  * @return integer the id, -1 if fails
  */
 public function get_last_insert_id($table, $field = '')
 {
     switch ($GLOBALS['phpgw_info']['server']['db_type']) {
         case 'postgres':
             $params = explode('.', $this->adodb->pgVersion);
             if ($params[0] < 8 || $params[0] == 8 && $params[1] == 0) {
                 $oid = pg_getlastoid($this->adodb->_resultid);
                 if ($oid == -1) {
                     return -1;
                 }
                 $result = @pg_Exec($this->adodb->_connectionID, "select {$field} from {$table} where oid={$oid}");
             } else {
                 $result = @pg_Exec($this->adodb->_connectionID, "select lastval()");
             }
             if (!$result) {
                 return -1;
             }
             $Record = @pg_fetch_array($result, 0);
             @pg_freeresult($result);
             if (!is_array($Record)) {
                 return -1;
             }
             return $Record[0];
             break;
         case 'mssql':
             /*  MSSQL uses a query to retrieve the last
              *  identity on the connection, so table and field are ignored here as well.
              */
             if (!isset($table) || $table == '' || !isset($field) || $field == '') {
                 return -1;
             }
             $result = @mssql_query("select @@identity", $this->adodb->_queryID);
             if (!$result) {
                 return -1;
             }
             return mssql_result($result, 0, 0);
             break;
         default:
             return $this->adodb->Insert_ID($table, $field);
     }
 }
 function _insertid($table, $column)
 {
     if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') {
         return false;
     }
     $oid = pg_getlastoid($this->_resultid);
     // to really return the id, we need the table and column-name, else we can only return the oid != id
     return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT CURRVAL('" . $table . "_" . $column . "_seq')");
 }