Author: uwendel
Date: 2008-03-11 15:44:08 +0100 (Tue, 11 Mar 2008)
New Revision: 1348
Added:
trunk/tests/ext/pdo_mysql/pdo_mysql_stmt_fetchobject.phpt
Log:
Postgres did not like this SQL syntax, moving parts of the generic test into a driver
specific one
Added: trunk/tests/ext/pdo_mysql/pdo_mysql_stmt_fetchobject.phpt
===================================================================
--- trunk/tests/ext/pdo_mysql/pdo_mysql_stmt_fetchobject.phpt (rev
0)
+++ trunk/tests/ext/pdo_mysql/pdo_mysql_stmt_fetchobject.phpt 2008-03-11 14:44:08 UTC (rev
1348)
@@ -0,0 +1,93 @@
+--TEST--
+MySQL PDO: PDOStatement->fetchObject()
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('mysql_pdo_test.inc');
+MySQLPDOTest::skip();
+$db = MySQLPDOTest::factory();
+?>
+--FILE--
+<?php
+require_once('mysql_pdo_test.inc');
+$db = MySQLPDOTest::factory();
+MySQLPDOTest::createTestTable($db);
+
+try {
+
+ // default settings
+ $query = "SELECT id, '', NULL, \"\" FROM test ORDER BY id ASC LIMIT 3";
+ $stmt = $db->prepare($query);
+
+ class myclass {
+
+ private $set_calls = 0;
+ protected static $static_set_calls = 0;
+
+ // NOTE: PDO does not care about protected
+ protected $grp;
+
+ // NOTE: PDO does not care about private and calls __construct() after __set()
+ private function __construct($param1, $param2) {
+ printf("myclass::__construct(%s, %s): %d / %d\n",
+ $param1, $param2,
+ self::$static_set_calls, $this->set_calls);
+ }
+
+ // NOTE: PDO will call __set() prior to calling __construct()
+ public function __set($prop, $value) {
+ $this->not_a_magic_one();
+ printf("myclass::__set(%s, -%s-) %d\n",
+ $prop, var_export($value, true), $this->set_calls, self::$static_set_calls);
+ $this->{$prop} = $value;
+ }
+
+ // NOTE: PDO can call regular methods prior to calling __construct()
+ public function not_a_magic_one() {
+ $this->set_calls++;
+ self::$static_set_calls++;
+ }
+
+ }
+ $stmt->execute();
+ $rowno = 0;
+ $rows[] = array();
+ while (is_object($rows[] = $stmt->fetchObject('myclass', array($rowno++, $rowno))))
+ ;
+
+ var_dump($rows[$rowno - 1]);
+
+} catch (PDOException $e) {
+ // we should never get here, we use warnings, but never trust a system...
+ printf("[001] %s, [%s} %s\n",
+ $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo()));
+}
+print "done!";
+?>
+--EXPECTF--
+myclass::__set(id, -'1'-) 1
+myclass::__set(, -''-) 2
+myclass::__set(null, -NULL-) 3
+myclass::__set(, -''-) 4
+myclass::__construct(0, 1): 4 / 4
+myclass::__set(id, -'2'-) 1
+myclass::__set(, -''-) 2
+myclass::__set(null, -NULL-) 3
+myclass::__set(, -''-) 4
+myclass::__construct(1, 2): 8 / 4
+myclass::__set(id, -'3'-) 1
+myclass::__set(, -''-) 2
+myclass::__set(null, -NULL-) 3
+myclass::__set(, -''-) 4
+myclass::__construct(2, 3): 12 / 4
+object(myclass)#%d (4) {
+ ["set_calls":"myclass":private]=>
+ int(4)
+ ["grp":protected]=>
+ NULL
+ ["id"]=>
+ string(1) "3"
+ ["null"]=>
+ NULL
+}
+done!
\ No newline at end of file
| Thread |
|---|
| • PHP mysqlnd svn commit: r1348 - trunk/tests/ext/pdo_mysql | uwendel | 12 Mar |