©
Dokumen ini menggunakan Manual laman web PHP Cina Lepaskan
(PECL maxdb >= 1.0)
maxdb_warning_count -- maxdb::warning_count — Returns the number of warnings from the last query for the given link
过程化风格
$link
)面向对象风格
maxdb_warning_count() returns the number of warnings
from the last query in the connection represented by the
link
parameter.
Number of warnings or zero if there are no warnings.
Example #1 面向对象风格
<?php
$maxdb = new maxdb ( "localhost" , "MONA" , "RED" , "DEMODB" );
if ( maxdb_connect_errno ()) {
printf ( "Connect failed: %s\n" , maxdb_connect_error ());
exit();
}
$maxdb -> query ( "CREATE TABLE temp.mycity LIKE hotel.city" );
$query = "INSERT INTO temp.mycity (zip, name) VALUES('11111',
'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')" ;
$maxdb -> query ( $query );
printf ( "Number of warning: %d\n" , $maxdb -> warning_count );
$maxdb -> close ();
?>
Example #2 过程化风格
<?php
$link = maxdb_connect ( "localhost" , "MONA" , "RED" , "DEMODB" );
if ( maxdb_connect_errno ()) {
printf ( "Connect failed: %s\n" , maxdb_connect_error ());
exit();
}
maxdb_query ( $link , "CREATE TABLE temp.mycity LIKE hotel.city" );
$query = "INSERT INTO temp.mycity (zip, name) VALUES('11111',
'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch')" ;
maxdb_query ( $link , $query );
printf ( "Number of warning: %d\n" , maxdb_warning_count ( $link ));
maxdb_close ( $link );
?>
以上例程的输出类似于:
Warning: maxdb_query(): -8004 POS(62) Constant must be compatible with column type and length <...> Number of warning: 0