Annotation of embedaddon/php/ext/mysql/tests/003.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: mysql_fetch_object
                      3: --SKIPIF--
                      4: <?php
                      5: require_once('skipif.inc');
                      6: require_once('skipifconnectfailure.inc');
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10: include_once('connect.inc');
                     11: 
                     12: class class24 {
                     13:        function __construct() {
                     14:                echo __METHOD__ . "\n";
                     15:        }
                     16: }
                     17: 
                     18: $data = array("one", "two", "three");
                     19: 
                     20: if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
                     21:        printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
                     22:                $host, $user, $db, $port, $socket);
                     23: 
                     24: if (!mysql_query('DROP TABLE IF EXISTS test', $link))
                     25:        printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));
                     26: 
                     27: if (!mysql_query("CREATE TABLE test(a varchar(10))", $link))
                     28:        printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
                     29: 
                     30: foreach ($data as $str) {
                     31:        if (!mysql_query(sprintf("INSERT INTO test VALUES('%s')", $str), $link))
                     32:                printf("[004 - %s] [%d] %s\n", $str, mysql_errno($link), mysql_error($link));
                     33: }
                     34: 
                     35: echo "==stdClass==\n";
                     36: if (!$res = mysql_query("SELECT a FROM test", $link))
                     37:        printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
                     38: 
                     39: while ($obj = mysql_fetch_object($res)) {
                     40:        var_dump($obj);
                     41: }
                     42: mysql_free_result($res);
                     43: 
                     44: echo "==class24==\n";
                     45: if (!$res = mysql_query("SELECT a FROM test", $link))
                     46:     printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
                     47: 
                     48: while ($obj = mysql_fetch_object($res, 'class24')) {
                     49:        var_dump($obj);
                     50: }
                     51: mysql_free_result($res);
                     52: mysql_close($link);
                     53: print "done!";
                     54: ?>
                     55: --CLEAN--
                     56: <?php
                     57: require_once("clean_table.inc");
                     58: ?>
                     59: --EXPECTF--
                     60: ==stdClass==
                     61: object(stdClass)#%d (1) {
                     62:   [%u|b%"a"]=>
                     63:   %unicode|string%(3) "one"
                     64: }
                     65: object(stdClass)#%d (1) {
                     66:   [%u|b%"a"]=>
                     67:   %unicode|string%(3) "two"
                     68: }
                     69: object(stdClass)#%d (1) {
                     70:   [%u|b%"a"]=>
                     71:   %unicode|string%(5) "three"
                     72: }
                     73: ==class24==
                     74: class24::__construct
                     75: object(class24)#%d (1) {
                     76:   [%u|b%"a"]=>
                     77:   %unicode|string%(3) "one"
                     78: }
                     79: class24::__construct
                     80: object(class24)#%d (1) {
                     81:   [%u|b%"a"]=>
                     82:   %unicode|string%(3) "two"
                     83: }
                     84: class24::__construct
                     85: object(class24)#%d (1) {
                     86:   [%u|b%"a"]=>
                     87:   %unicode|string%(5) "three"
                     88: }
                     89: done!

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