简体   繁体   English

PHP mssql_affected_rows与mssql_rows_affected

[英]PHP mssql_affected_rows vs mssql_rows_affected

I use PHP 5.4.24 with Microsoft SQL Server 2008r2, both on Windows and Linux. 我在Windows和Linux上都将PHP 5.4.24与Microsoft SQL Server 2008r2一起使用。 On Linux, I use freetds-0.91-clean. 在Linux上,我使用freetds-0.91-clean。 On Windows, in phpinfo() the mssql extension says "Library version: FreeTDS" 在Windows上,在phpinfo()中,mssql扩展名显示“库版本:FreeTDS”

The function mssql_affected_rows: 函数mssql_affected_rows:

  • Works on Linux, but not on Windows 在Linux上可用,但在Windows上不可用
  • Is consistent with other databases (eg sybase_affected_rows, mysql_affected_rows, pg_affected_rows) 与其他数据库(例如sybase_affected_rows,mysql_affected_rows,pg_affected_rows)一致
  • Is not documented on www.php.net 没有记录在www.php.net上

The function mssql_rows_affected: 函数mssql_rows_affected:

  • Works on Windows, but not on Linux 在Windows上有效,但在Linux上无效
  • Is not consistent with other databases (eg sybase_affected_rows, mysql_affected_rows, pg_affected_rows) 与其他数据库不一致(例如sybase_affected_rows,mysql_affected_rows,pg_affected_rows)
  • Is documented on www.php.net 在www.php.net上有记录

Why these two names? 为什么要用这两个名字? This makes hard to have the same code running on both systems. 这使得很难在两个系统上运行相同的代码。

For future readers, here is a wrapper that I wrote that works in both cases: 对于将来的读者,这是我写的包装,在两种情况下都适用:

function GetAffectedRows()
    {
    if ( function_exists( 'mssql_affected_rows' ) )
        return mssql_affected_rows( $Conn ) ;
    else
        return mssql_rows_affected( $Conn ) ;
    }

Reference: http://php.net/manual-lookup.php?pattern=mssql_affected_rows 参考: http : //php.net/manual-lookup.php?pattern=mssql_affected_rows

PHP is inconsistent in many ways, someone said it has a "fractal bad design" and it's true.... in every aspect and update more and more fails. PHP在许多方面都是不一致的,有人说它的设计很“分形”,这是真的。。。在各个方面,并且更新越来越失败。

For me and many others the order of needle / haystack in functions is exasperating without an IDE or at least a good editor as notepad++ / ST 对我和其他许多人来说,没有IDE或至少没有一个好的记事本++ / ST的情况下,函数中的needle / haystack的顺序令人不安

http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM