8288分类目录 8288分类目录 8288分类目录
  当前位置:海洋目录网 » 站长资讯 » 站长资讯 » 文章详细 订阅RssFeed

PHP - Manual: mysqlnd_ms_get_last_gtid

来源:网络转载 浏览:37925次 时间:2023-09-02
mysqlnd_ms_get_last_used_connection » « mysqlnd_ms_fabric_select_shard
  • PHP 手册
  • 函数参考
  • 数据库扩展
  • 针对各数据库系统对应的扩展
  • MySQL
  • mysqlnd_ms
  • Mysqlnd_ms 函数

mysqlnd_ms_get_last_gtid

(PECL mysqlnd_ms >= 1.2.0)

mysqlnd_ms_get_last_gtid — 返回最后的全局同步 ID (GTID)

说明

mysqlnd_ms_get_last_gtid ( mixed $connection ) : string

返回最后一次写操作以后的 GTID,他并不能保证一定是那次写操作产生的 GTID,但是得到的 GTID 一定比这次写操作产生的 GTID 大。

参数

connection

由 PDO_MYSQL, mysqli> 或者 ext/mysql 产生的 MySQL 服务器连接, 这些链接受 PECL/mysqlnd_ms 连接控制。连接的创建是通过 mysqlnd_ms 配置文件中 约定的群组名称建立的。

返回值

成功返回 GTID,失败返回 FALSE

函数通过配置文件中 global_transaction_id_injection 章节定义的 fetch_last_gtid 参数来获取 GTID。

在函数调用的时候,GTID 可能已经增加了。

注释

Note:

函数需要 PHP >= 5.4.0 版本,PECL/mysqlnd_ms >= 1.2.0 版本,在 PHP 5.3 版本中 mysqlnd 库不能使用。

范例

Example #1 mysqlnd_ms_get_last_gtid() example

<?php
/* Open mysqlnd_ms connection using mysqli, PDO_MySQL or mysql extension */
$mysqli = new mysqli("myapp", "username", "password", "database");
if (!$mysqli)
  /* Of course, your error handling is nicer... */
  die(sprintf("[%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));

/* auto commit mode, transaction on master, GTID must be incremented */
if (!$mysqli->query("DROP TABLE IF EXISTS test"))
  die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));

printf("GTID after transaction %s\n", mysqlnd_ms_get_last_gtid($mysqli));

/* auto commit mode, transaction on master, GTID must be incremented */
if (!$mysqli->query("CREATE TABLE test(id INT)"))
  die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));

printf("GTID after transaction %s\n", mysqlnd_ms_get_last_gtid($mysqli));
?>

参见

  • Global Transaction IDs
add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.mysqlnd-ms-get-last-gtid.php

  推荐站点

  • At-lib分类目录At-lib分类目录

    At-lib网站分类目录汇集全国所有高质量网站,是中国权威的中文网站分类目录,给站长提供免费网址目录提交收录和推荐最新最全的优秀网站大全是名站导航之家

    www.at-lib.cn
  • 中国链接目录中国链接目录

    中国链接目录简称链接目录,是收录优秀网站和淘宝网店的网站分类目录,为您提供优质的网址导航服务,也是网店进行收录推广,站长免费推广网站、加快百度收录、增加友情链接和网站外链的平台。

    www.cnlink.org
  • 35目录网35目录网

    35目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向35目录推荐、提交优秀网站。

    www.35mulu.com
  • 就要爱网站目录就要爱网站目录

    就要爱网站目录,按主题和类别列出网站。所有提交的网站都经过人工审查,确保质量和无垃圾邮件的结果。

    www.912219.com
  • 伍佰目录伍佰目录

    伍佰网站目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向伍佰目录推荐、提交优秀网站。

    www.wbwb.net