--TEST-- datetime objects as fields and as parameters. --SKIPIF-- --FILE-- var; } } $simple_class = new SimpleClass(); $stmt = sqlsrv_query($conn, "INSERT INTO [php_table_SERIL1_1] (c2_smalldatetime) VALUES (?)", array( $simple_class )); if( $stmt !== false ) { die( "class should have failed." ); } print_r( sqlsrv_errors() ); sqlsrv_query($conn, "DROP TABLE [php_table_SERIL1_1]"); sqlsrv_close($conn); echo "test succeeded."; ?> --EXPECTF-- 1963-02-01 20:56:00.000000 1963-02-01 20:56:00.000000 1963-02-01 20:56:00.000000 1963-02-01 20:56:00.000000 1963-02-01 20:56:00.000000 1963-02-01 20:56:00.000000 Array ( [0] => Array ( [0] => 22007 [SQLSTATE] => 22007 [1] => 242 [code] => 242 [2] => %SThe conversion of a datetimeoffset data type to a smalldatetime data type resulted in an out-of-range value. [message] => %SThe conversion of a datetimeoffset data type to a smalldatetime data type resulted in an out-of-range value. ) [1] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 3621 [code] => 3621 [2] => %SThe statement has been terminated. [message] => %SThe statement has been terminated. ) ) Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -16 [code] => -16 [2] => An invalid PHP type for parameter 1 was specified. [message] => An invalid PHP type for parameter 1 was specified. ) ) test succeeded.