/hphp/test/zend/bad/ext/mysql/tests/003.php
PHP | 50 lines | 40 code | 10 blank | 0 comment | 8 complexity | f20d5271811a8d4504eda3d24293b7a0 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
- <?php
- include_once('connect.inc');
- class class24 {
- function __construct() {
- echo __METHOD__ . "\n";
- }
- }
- $data = array("one", "two", "three");
- if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket))
- printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
- $host, $user, $db, $port, $socket);
- if (!mysql_query('DROP TABLE IF EXISTS test', $link))
- printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));
- if (!mysql_query("CREATE TABLE test(a varchar(10))", $link))
- printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
- foreach ($data as $str) {
- if (!mysql_query(sprintf("INSERT INTO test VALUES('%s')", $str), $link))
- printf("[004 - %s] [%d] %s\n", $str, mysql_errno($link), mysql_error($link));
- }
- echo "==stdClass==\n";
- if (!$res = mysql_query("SELECT a FROM test", $link))
- printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
- while ($obj = mysql_fetch_object($res)) {
- var_dump($obj);
- }
- mysql_free_result($res);
- echo "==class24==\n";
- if (!$res = mysql_query("SELECT a FROM test", $link))
- printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
- while ($obj = mysql_fetch_object($res, 'class24')) {
- var_dump($obj);
- }
- mysql_free_result($res);
- mysql_close($link);
- print "done!";
- ?>
- <?php error_reporting(0); ?>
- <?php
- require_once("clean_table.inc");
- ?>