当前位置: 首页>>代码示例>>PHP>>正文


PHP pg_last_oid函数代码示例

本文整理汇总了PHP中pg_last_oid函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_last_oid函数的具体用法?PHP pg_last_oid怎么用?PHP pg_last_oid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pg_last_oid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: castResult

 public static function castResult($result, array $a, Stub $stub, $isNested)
 {
     $a['num rows'] = pg_num_rows($result);
     $a['status'] = pg_result_status($result);
     if (isset(self::$resultStatus[$a['status']])) {
         $a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
     }
     $a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING);
     if (-1 === $a['num rows']) {
         foreach (self::$diagCodes as $k => $v) {
             $a['error'][$k] = pg_result_error_field($result, $v);
         }
     }
     $a['affected rows'] = pg_affected_rows($result);
     $a['last OID'] = pg_last_oid($result);
     $fields = pg_num_fields($result);
     for ($i = 0; $i < $fields; ++$i) {
         $field = array('name' => pg_field_name($result, $i), 'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)), 'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)), 'nullable' => (bool) pg_field_is_null($result, $i), 'storage' => pg_field_size($result, $i) . ' bytes', 'display' => pg_field_prtlen($result, $i) . ' chars');
         if (' (OID: )' === $field['table']) {
             $field['table'] = null;
         }
         if ('-1 bytes' === $field['storage']) {
             $field['storage'] = 'variable size';
         } elseif ('1 bytes' === $field['storage']) {
             $field['storage'] = '1 byte';
         }
         if ('1 chars' === $field['display']) {
             $field['display'] = '1 char';
         }
         $a['fields'][] = new EnumStub($field);
     }
     return $a;
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:33,代码来源:PgSqlCaster.php

示例2: lastId

 public function lastId()
 {
     $re = $this->connectionId ? @pg_last_oid($this->connectionId) : false;
     if (!$re) {
         throw new Exception($this->errorInfo());
     }
     return $re;
 }
开发者ID:ravenlp,项目名称:FlavorPHP,代码行数:8,代码来源:pgsql_db.class.php

示例3: create

 public static function create($entry, $body, $author, $author_ip)
 {
     if (!$entry->id || !trim($body)) {
         return null;
     }
     $result = pg_query("insert into comments (entry_id, body, author, author_ip) values ('" . pesc($entry->id) . "', '" . pesc($body) . "', '" . pesc($author) . "', '" . pesc($author_ip) . "')");
     if (!($id = pg_last_oid($result))) {
         return null;
     }
     return self::from_row(pg_query("select * from comments where id = '" . pesc($id) . "'"));
 }
开发者ID:bakineggs,项目名称:bakineggs.com,代码行数:11,代码来源:comment.php

示例4: save

 public function save()
 {
     if ($this->id == 0) {
         $this->id = pg_last_oid(pg_query("insert into cars () values ()"));
         self::$_rows[$this->id] = array();
     }
     self::$_rows[$this->id]['id'] = $this->id;
     self::$_rows[$this->id]['price'] = $this->price;
     self::$_rows[$this->id]['make'] = $this->make;
     self::$_rows[$this->id]['model'] = $this->model;
     self::$_rows[$this->id]['year'] = $this->year;
     self::$_rows[$this->id]['mileage'] = $this->mileage;
     self::$_rows[$this->id]['vin'] = $this->vin;
     self::$_rows[$this->id]['uri'] = $this->uri;
     self::$_rows[$this->id]['dealer'] = $this->dealer;
     $updates = array();
     foreach (self::$_rows[$this->id] as $col => $val) {
         $updates[] = pesc($col) . '=' . pesc($val);
     }
     pg_query('update cars set ' . implode(', ', $updates) . ' where id=\'' . pesc($this->id) . '\'');
     $this->loadVariables();
 }
开发者ID:bakineggs,项目名称:cars,代码行数:22,代码来源:car.inc.php

示例5: serendipity_db_insert_id

/**
 * Returns the latest INSERT_ID of an SQL INSERT INTO command, for auto-increment columns
 *
 * @access public
 * @param  string   Name of the table to get a INSERT ID for
 * @param  string   Name of the column to get a INSERT ID for
 * @return int      Value of the auto-increment column
 */
function serendipity_db_insert_id($table = '', $id = '')
{
    global $serendipity;
    if (empty($table) || empty($id)) {
        // BC - will/should never be called with empty parameters!
        return pg_last_oid($serendipity['dbLastResult']);
    } else {
        $query = "SELECT currval('{$serendipity['dbPrefix']}{$table}_{$id}_seq'::text) AS {$id}";
        $res = pg_query($serendipity['dbConn'], $query);
        if (pg_num_rows($res)) {
            $insert_id = pg_fetch_array($res, 0, PGSQL_ASSOC);
            return $insert_id[$id];
        } else {
            return pg_last_oid($serendipity['dbLastResult']);
            // BC - should not happen!
        }
    }
}
开发者ID:jimjag,项目名称:Serendipity,代码行数:26,代码来源:postgres.inc.php

示例6: get_insert_id

 function get_insert_id($query)
 {
     $this->last_oid = pg_last_oid($this->result);
     if (empty($this->last_oid)) {
         return '';
     }
     // try to find table name
     eregi("insert *into *([^ ]+).*", $query, $regs);
     //print_r($regs);
     $table_name = $regs[1];
     $query_for_id = "SELECT * FROM {$table_name} WHERE oid='{$this->last_oid}'";
     //echo $query_for_id."<br>";
     $result_for_id = pg_query($this->dbh, $query_for_id);
     if (pg_num_rows($result_for_id)) {
         $id = pg_fetch_array($result_for_id, 0, PGSQL_NUM);
         //print_r($id);
         return $id[0];
     }
 }
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:19,代码来源:ezsql_postgres.php

示例7: getInsertID

 public function getInsertID()
 {
     return pg_last_oid($this->result[$name]);
 }
开发者ID:rawork,项目名称:colors-life,代码行数:4,代码来源:pgConnector.php

示例8: insert_id

 /**
  * Insert ID
  *
  * @access	public
  * @return	integer
  */
 function insert_id()
 {
     return pg_last_oid($this->result_id);
 }
开发者ID:Calico90,项目名称:codeigniter-version-scan,代码行数:10,代码来源:DB_postgre.php

示例9: last_insert_id

 function last_insert_id(&$result, $pkfield, $table)
 {
     // returns the id of the most recently modified record
     trigger_before('last_insert_id', $this, $this);
     global $prefix;
     $oid = @pg_last_oid($result);
     if (!$oid) {
         trigger_error(@pg_last_error($this->conn), E_USER_ERROR);
     }
     $sql = "SELECT " . $pkfield . " FROM " . $prefix . $table . " WHERE oid = " . $oid;
     $res = $this->get_result($sql);
     if (!$res) {
         trigger_error("error in last_insert_id in postgresql.php" . @pg_last_error($this->conn), E_USER_ERROR);
     } else {
         return $this->result_value($res, 0, $pkfield);
     }
 }
开发者ID:voitto,项目名称:dbscript,代码行数:17,代码来源:postgresql.php

示例10: _performQuery

 function _performQuery($queryMain)
 {
     $this->_lastQuery = $queryMain;
     $isInsert = preg_match('/^\\s* INSERT \\s+/six', $queryMain[0]);
     //
     // Note that in case of INSERT query we CANNOT work with prepare...execute
     // cache, because RULEs do not work after pg_execute(). This is a very strange
     // bug... To reproduce:
     //   $DB->query("CREATE TABLE test(id SERIAL, str VARCHAR(10)) WITH OIDS");
     //   $DB->query("CREATE RULE test_r AS ON INSERT TO test DO (SELECT 111 AS id)");
     //   print_r($DB->query("INSERT INTO test(str) VALUES ('test')"));
     // In case INSERT + pg_execute() it returns new row OID (numeric) instead
     // of result of RULE query. Strange, very strange...
     //
     if ($this->DbSimple_Postgresql_USE_NATIVE_PHOLDERS && !$isInsert) {
         // Use native placeholders only if PG supports them.
         $this->_expandPlaceholders($queryMain, true);
         $hash = md5($queryMain[0]);
         if (!isset($this->prepareCache[$hash])) {
             $prepared = @pg_prepare($this->link, $hash, $queryMain[0]);
             if ($prepared === false) {
                 return $this->_setDbError($queryMain[0]);
             } else {
                 $this->prepareCache[$hash] = true;
             }
         } else {
             // Prepare cache hit!
         }
         $result = pg_execute($this->link, $hash, array_slice($queryMain, 1));
     } else {
         // No support for native placeholders on INSERT query.
         $this->_expandPlaceholders($queryMain, false);
         $result = @pg_query($this->link, $queryMain[0]);
     }
     if ($result === false) {
         return $this->_setDbError($queryMain);
     }
     if (!pg_num_fields($result)) {
         if ($isInsert) {
             // INSERT queries return generated OID (if table is WITH OIDs).
             //
             // Please note that unfortunately we cannot use lastval() PostgreSQL
             // stored function because it generates fatal error if INSERT query
             // does not contain sequence-based field at all. This error terminates
             // the current transaction, and we cannot continue to work nor know
             // if table contains sequence-updateable field or not.
             //
             // To use auto-increment functionality you must invoke
             //   $insertedId = $DB->query("SELECT lastval()")
             // manually where it is really needed.
             //
             return @pg_last_oid($result);
         }
         // Non-SELECT queries return number of affected rows, SELECT - resource.
         return @pg_affected_rows($result);
     }
     return $result;
 }
开发者ID:Sarjuuk,项目名称:DbSimple,代码行数:58,代码来源:Postgresql.php

示例11: insert_id

 public function insert_id()
 {
     return pg_last_oid($this->connection);
 }
开发者ID:natas333x2,项目名称:kg-geodata,代码行数:4,代码来源:database.php

示例12: lastInsertId

 public function lastInsertId()
 {
     return $this->_result ? pg_last_oid($this->_result) : 0;
 }
开发者ID:chaobj001,项目名称:tt,代码行数:4,代码来源:DoPgsql.php

示例13: ultimo_insertado

 function ultimo_insertado($enlace = "")
 {
     return pg_last_oid($enlace);
 }
开发者ID:udistrital,项目名称:serviciosacademicos_desarrollo,代码行数:4,代码来源:pgsql.class.php

示例14: LastOID

 function LastOID()
 {
     if (version_compare(phpversion(), "4.2.0", "ge") > 0) {
         $this->oid = pg_last_oid($this->result);
     }
     return $this->oid;
 }
开发者ID:rmittalsfdc,项目名称:Search,代码行数:7,代码来源:postgredb.php

示例15: vmoodle_execute_query

/**
 * Executes a query on a Vmoodle database. Query must return no results,
 * so it may be an INSERT or an UPDATE or a DELETE.
 * @param object $vmoodle The Vmoodle object.
 * @param string $sql The SQL request.
 * @param handle $cnx The connection to the Vmoodle database.
 * @return boolean true if the request is well-executed, false otherwise.
 */
function vmoodle_execute_query(&$vmoodle, $sql, $cnx)
{
    // If database is MySQL typed.
    if ($vmoodle->vdbtype == 'mysql') {
        if (!($res = mysql_query($sql, $cnx))) {
            echo "vmoodle_execute_query() : " . mysql_error($cnx) . "<br/>";
            return false;
        }
        if ($newid = mysql_insert_id($cnx)) {
            $res = $newid;
            // get the last insert id in case of an INSERT
        }
    } elseif ($vmoodle->vdbtype == 'postgres') {
        if (!($res = pg_query($cnx, $sql))) {
            echo "vmoodle_execute_query() : " . pg_last_error($cnx) . "<br/>";
            return false;
        }
        if ($newid = pg_last_oid($res)) {
            $res = $newid;
            // Get the last insert id in case of an INSERT.
        }
    } else {
        echo "vmoodle_execute_query() : Database not supported<br/>";
        return false;
    }
    return $res;
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:35,代码来源:lib.php


注:本文中的pg_last_oid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。