本文整理汇总了PHP中pg_getlastoid函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_getlastoid函数的具体用法?PHP pg_getlastoid怎么用?PHP pg_getlastoid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pg_getlastoid函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _insertid
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);
}
示例2: _insertid
function _insertid()
{
return pg_getlastoid($this->_resultid);
}
示例3: _insertid
function _insertid()
{
if (!is_resource($this->_resultid)) {
return false;
}
return pg_getlastoid($this->_resultid);
}
示例4: getInsertID
function getInsertID()
{
return pg_getlastoid($this->result[$this->stack_last]);
}
示例5: _insertid
function _insertid()
{
if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') {
return false;
}
return pg_getlastoid($this->_resultid);
}
示例6: db_last_oid
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);
}
示例7: db_insertid
/**
*
* 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;
}
}
示例8: get_last_insert_id
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];
}
示例9: _insertid
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");
}
示例10: pg_connect
<?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";
示例11: insert_id
/**
* Return the last insert ID
* @return integer
*/
protected function insert_id()
{
return @pg_getlastoid($this->resResult);
}
示例12: Add_table
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;
}
示例13: get_last_insert_id
/**
* 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);
}
}
示例14: _insertid
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')");
}