cvs: pear /MDB MDB_test.php
| From: | Lukas Smith | Date: | Thu, 20 Jun 2002 12:07:59 +0000 |
| Subject: | cvs: pear /MDB MDB_test.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4708@lists.php.net to get a copy of this message | ||
lsmith Thu Jun 20 08:07:59 2002 EDT
Modified files:
/pear/MDB MDB_test.php
Log:
added test for subSelect()
commented out the manager section for now until the pgsql driver has this working
added optional parameter db_type to specify which database type should be used
Index: pear/MDB/MDB_test.php
diff -u pear/MDB/MDB_test.php:1.10 pear/MDB/MDB_test.php:1.11
--- pear/MDB/MDB_test.php:1.10 Wed Jun 12 09:10:54 2002
+++ pear/MDB/MDB_test.php Thu Jun 20 08:07:58 2002
@@ -1,7 +1,7 @@
<?php
/*
*
- * @(#) $Header: /usr/repository/pear/MDB/MDB_test.php,v 1.10 2002/06/12 13:10:54 lsmith Exp $
+ * @(#) $Header: /usr/repository/pear/MDB/MDB_test.php,v 1.11 2002/06/20 12:07:58 lsmith Exp $
*
*/
// MDB.php doesnt have to be included since manager.php does that
@@ -16,8 +16,14 @@
//$pass = "";
$host = 'localhost';
$db_name = 'metapear_test_db';
+ if(isset($_GET["db_type"])) {
+ $db_type = $_GET["db_type"];
+ } else {
$db_type = "mysql";
+ }
+ echo $db_type."<br>";
+/*
// just for kicks you can mess up this part to see some pear error handling
$dsn["username"] = $user;
$dsn["password"] = $pass;
@@ -34,7 +40,7 @@
// in that case MDb will just compare the two schemas and make any necessary modifications to
the existing DB
$result = $manager->updateDatabase($input_file, $input_file.".before", $dsn,
$database_variables);
echo "updating database from xml schema file<br>";
-
+*/
// Data Source Name: This is the universal connection string
$dsn = "$db_type://$user:$pass@$host/$db_name";
@@ -56,7 +62,7 @@
// run the query and get a result handler
$result = $db->query($query);
// lets just get row:0 column:0 and free the result
- $db->fetchField($result, $field);
+ $db->fetchOne($result, $field);
echo "<br>field:<br>".$field."<br>";
// run the query and get a result handler
$result = $db->query($query);
@@ -146,8 +152,17 @@
echo Var_Dump::display($db->tableInfo("numbers"))."<br>";
echo "<br>just a simple delete query:<br>";
echo Var_Dump::display($db->query("DELETE FROM numbers"))."<br>";
-
-
+ // subselect test
+ $sub_select = $db->subSelect("SELECT test_name from test WHERE test_name =
".$db->getTextFieldValue('gummihuhn'), TRUE);
+ $query_with_subselect = "SELECT * FROM test WHERE test_name IN
(".$sub_select.")";
+ // run the query and get a result handler
+ echo $query_with_subselect."<br>";
+ $result = $db->query($query_with_subselect);
+ $db->fetchAll($result, &$array);
+ echo "<br>all with subselect:<br>";
+ echo Var_Dump::display($array)."<br>";
+
+ /*
// ok now lets create a new xml schema file from the existing DB
// we will not use the 'metapear_test_db.schema' for this
// this feature is especially interesting for people that have an existing Db and want to move
to MDB's xml schema management
@@ -169,4 +184,5 @@
if($manager->database) {
echo $manager->database->debugOutput();
}
+ */
?>