You are here

protected function OAuthStorePostgreSQL::query_insert_id in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.7 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::query_insert_id()
  2. 7.2 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::query_insert_id()
  3. 7.3 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::query_insert_id()
  4. 7.4 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::query_insert_id()
  5. 7.6 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::query_insert_id()

Return the id of the last inserted row

Return value

int

1 call to OAuthStorePostgreSQL::query_insert_id()
OAuthStorePostgreSQL::updateServer in lib/oauth-php/library/store/OAuthStorePostgreSQL.php
Register or update a server for our site (we will be the consumer)

File

lib/oauth-php/library/store/OAuthStorePostgreSQL.php, line 1888

Class

OAuthStorePostgreSQL

Code

protected function query_insert_id($tableName, $primaryKey = null) {
  $sequenceName = $tableName;
  if ($primaryKey) {
    $sequenceName .= "_{$primaryKey}";
  }
  $sequenceName .= '_seq';
  $sql = "\n            SELECT\n                CURRVAL('%s')\n                ";
  $args = array(
    $sql,
    $sequenceName,
  );
  $sql = $this
    ->sql_printf($args);
  if (!($res = pg_query($this->conn, $sql))) {
    return 0;
  }
  $val = pg_fetch_row($res, 0);
  if ($val && isset($val[0])) {
    $val = $val[0];
  }
  pg_free_result($res);
  return $val;
}