Giter Site home page Giter Site logo

Comments (5)

mowangjuanzi avatar mowangjuanzi commented on September 25, 2024

我仔细看了一下该文档。该文档在任何情况下,都不会返回 -1 。请问你觉得应该是在什么情况下,会返回 -1 呢?

from doc-zh.

playadmin avatar playadmin commented on September 25, 2024

当指定插入数据的主键是-1的时候

from doc-zh.

mowangjuanzi avatar mowangjuanzi commented on September 25, 2024

我去追了一下源码。可能还真是 PHP 的 bug。可以看这里的代码:

https://github.com/php/php-src/blob/master/ext/pdo_mysql/mysql_driver.c#L292

/* {{{ pdo_mysql_last_insert_id */
static zend_string *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const zend_string *name)
{
	pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
	PDO_DBG_ENTER("pdo_mysql_last_insert_id");
	PDO_DBG_RETURN(zend_u64_to_str(mysql_insert_id(H->server)));
}
/* }}} */

zend_u64_to_str。问题主要在这里。它默认将其认为是 unsigned long int。实际上这个返回值既有可能是 unsigned long int 也有可能是 long int 。既然是你发现的,我觉得你可以跟官方报告下这个问题。如果不方便,我也可以代为提交。😀

from doc-zh.

playadmin avatar playadmin commented on September 25, 2024

嗯明显是把有符号的也当作无符号返回了。
那就麻烦你提交吧~

from doc-zh.

mowangjuanzi avatar mowangjuanzi commented on September 25, 2024

php/doc-en#1930 可以看一下这里的讨论

from doc-zh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.