Annotation of embedaddon/php/ext/sybase_ct/tests/test.inc, revision 1.1.1.1

1.1       misho       1: <?php
                      2: /* This file is part of PHP test framework for ext/sybase_ct
                      3:  *
                      4:  * $Id: test.inc 268732 2008-11-10 11:00:48Z thekid $ 
                      5:  */
                      6: 
                      7:   // Change if needed
                      8:   define('HOST',     getenv('PHP_SYBASE_HOST'));
                      9:   define('USER',     getenv('PHP_SYBASE_USER'));
                     10:   define('PASSWORD', getenv('PHP_SYBASE_PASS'));
                     11:   define('TEMPDB',   'tempdb');
                     12: 
                     13:   // {{{ bool sybase_msg_handler(int msgnumber, int severity, int state, int line, string text)
                     14:   //     Handles server messages
                     15:   function sybase_msg_handler($msgnumber, $severity, $state, $line, $text) {
                     16:     printf(
                     17:       "*** Caught Sybase Server Message #%d [Severity %d, state %d] at line %d\n    '%s'\n",
                     18:       $msgnumber,
                     19:       $severity,
                     20:       $state,
                     21:       $line,
                     22:       chop($text)
                     23:     );
                     24:   }
                     25:   // }}}
                     26: 
                     27:   // {{{ public class sybase
                     28:   class sybase {
                     29:   
                     30:     // {{{ public static bool static_handler(int msgnumber, int severity, int state, int line, string text)
                     31:     //     Handles server messages
                     32:     static function static_handler($msgnumber, $severity, $state, $line, $text) {
                     33:       return sybase_msg_handler($msgnumber, $severity, $state, $line, $text);
                     34:     }
                     35:     // }}}
                     36: 
                     37:     // {{{ public bool static_handler(int msgnumber, int severity, int state, int line, string text)
                     38:     //     Handles server messages
                     39:     function handler($msgnumber, $severity, $state, $line, $text) { 
                     40:       return sybase_msg_handler($msgnumber, $severity, $state, $line, $text);
                     41:     }
                     42:     // }}}
                     43:   }
                     44:   // }}}
                     45: 
                     46:   // {{{ void sybase_set_messagehandler_ex(string handler)
                     47:   //     Sets the sybase message handler and dumps the result
                     48:   function sybase_set_messagehandler_ex($handler) {
                     49:     var_dump(sybase_set_message_handler($handler));
                     50:   }
                     51:   
                     52:   // {{{ resource sybase_connect_ex(string charset= NULL, string appname= NULL, bool new= FALSE)
                     53:   //     Connect to the sybase server using the defines HOST, USER and PASSWORD
                     54:   function sybase_connect_ex($charset= NULL, $appname= NULL, $new= FALSE) {
                     55:     sybase_min_server_severity(11);       // Suppress "changed database context"
                     56:     if (!($db= sybase_connect(HOST, USER, PASSWORD, $charset ? $charset : 'iso_1', $appname, $new))) {
                     57:       die('Connect to '.USER.'@'.HOST.' failed (using password: '.(PASSWORD ? 'yes' : 'no').')');
                     58:     }
                     59:     return $db;
                     60:   }
                     61:   // }}}
                     62: 
                     63:   // {{{ void sybase_select_ex(resource dbh, string query)
                     64:   //     Returns all fetched rows from an SQL query
                     65:   function sybase_select_ex($dbh, $query) {
                     66:     printf(">>> Query: %s\n", $query);
                     67:     $h= sybase_query($query, $dbh);
                     68:     printf("<<< Return: %s\n", gettype($h));
                     69:     flush();
                     70:     if (!is_resource($h)) return $h;
                     71: 
                     72:     $return= array();
                     73:     while ($row= sybase_fetch_assoc($h)) {
                     74:       $return[]= $row;
                     75:     }
                     76:     return $return;
                     77:   }
                     78:   
                     79:   // {{{ mixed sybase_select_single(resource dbh, string query)
                     80:   //     Fires an SQL query and returns the first value from the first row
                     81:   function sybase_select_single($dbh, $query) {
                     82:     $a = sybase_fetch_row(sybase_query($query, $dbh));
                     83:     return array_shift($a);
                     84:   }
                     85:   // }}}
                     86: ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>