Annotation of embedaddon/php/ext/sybase_ct/tests/test_msghandler_handled.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Sybase-CT server message handler
! 3: --SKIPIF--
! 4: <?php require('skipif.inc'); ?>
! 5: --FILE--
! 6: <?php
! 7: /* This file is part of PHP test framework for ext/sybase_ct
! 8: *
! 9: * $Id: test_msghandler_handled.phpt 236103 2007-05-22 11:38:57Z thekid $
! 10: */
! 11:
! 12: require('test.inc');
! 13:
! 14: // {{{ bool sybase_msg_handler(int msgnumber, int severity, int state, int line, string text)
! 15: // Handles server messages
! 16: function user_message_handler($msgnumber, $severity, $state, $line, $text) {
! 17: switch ($msgnumber) {
! 18: case 0: // print message
! 19: printf("!!! %s\n", trim($text));
! 20: return;
! 21:
! 22: case 174: // The function 'GETDATE' requires 0 arguments.
! 23: case 11021: // Function GETDATE invoked with wrong number or type of argument(s)
! 24: printf("*** Caught '%s'\n", trim($text));
! 25: return;
! 26: }
! 27: printf("Cannot handle message #%d\n", $msgnumber);
! 28: return FALSE; // Indicate we can't handle this
! 29: }
! 30: // }}}
! 31:
! 32: sybase_set_messagehandler_ex('user_message_handler');
! 33: $db= sybase_connect_ex();
! 34: sybase_min_server_severity(0);
! 35:
! 36: // These are handled
! 37: var_dump(sybase_select_ex($db, 'select getdate(NULL)'));
! 38: var_dump(sybase_select_ex($db, 'print "Hi"'));
! 39:
! 40: // These aren't
! 41: var_dump(sybase_select_ex($db, 'use NULL'));
! 42: var_dump(sybase_select_ex($db, 'select convert(datetime, "notadate")'));
! 43:
! 44: sybase_close($db);
! 45: ?>
! 46: --EXPECTF--
! 47: bool(true)
! 48: >>> Query: select getdate(NULL)
! 49: *** Caught '%s'
! 50: <<< Return: boolean
! 51: bool(false)
! 52: >>> Query: print "Hi"
! 53: !!! Hi
! 54: <<< Return: boolean
! 55: bool(true)
! 56: >>> Query: use NULL
! 57: Cannot handle message #156
! 58:
! 59: Warning: sybase_query(): Sybase: Server message: Incorrect syntax near the keyword 'NULL'.
! 60: (severity 15, procedure N/A) in %s on line %d
! 61: <<< Return: boolean
! 62: bool(false)
! 63: >>> Query: select convert(datetime, "notadate")
! 64: Cannot handle message #249
! 65:
! 66: Warning: sybase_query(): Sybase: Server message: Syntax error during explicit conversion of VARCHAR value 'notadate' to a DATETIME field.
! 67: (severity 16, procedure N/A) in %s on line %d
! 68: <<< Return: boolean
! 69: bool(false)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>