From 8df3db566a3a937b45ebf11adb90d265e6f5e2d4 Mon Sep 17 00:00:00 2001
From: Andreas Baumann ";
+ return;
+ }
+ $arr = $rs->GetArray();
+ //$db->debug = true;
+ global $ADODB_COUNTRECS;
+ $ADODB_COUNTRECS = false;
+ $start = microtime();
+ for ($i=0; $i < $max; $i++) {
+ $rs = $db->Execute($sql);
+ $arr = $rs->GetArray();
+ // print $arr[0][1];
+ }
+ $end = microtime();
+ $start = explode(' ',$start);
+ $end = explode(' ',$end);
+
+ //print_r($start);
+ //print_r($end);
+
+ // print_r($arr);
+ $total = $end[0]+trim($end[1]) - $start[0]-trim($start[1]);
+ printf (" seconds = %8.2f for %d iterations each with %d records $url ";
+ print " Output of getAttributeNames: ";
+ var_dump($person->getAttributeNames());
+
+ /**
+ * Outputs the following:
+ * array(4) {
+ * [0]=>
+ * string(2) "id"
+ * [1]=>
+ * string(9) "name_first"
+ * [2]=>
+ * string(8) "name_last"
+ * [3]=>
+ * string(13) "favorite_color"
+ * }
+ */
+
+ $person = new Person();
+ $person->name_first = 'Andi';
+ $person->name_last = 'Gutmans';
+ $person->save(); // this save() will fail on INSERT as favorite_color is a must fill...
+
+
+ $person = new Person();
+ $person->name_first = 'Andi';
+ $person->name_last = 'Gutmans';
+ $person->favorite_color = 'blue';
+ $person->save(); // this save will perform an INSERT successfully
+
+ echo " The Insert ID generated:"; print_r($person->id);
+
+ $person->favorite_color = 'red';
+ $person->save(); // this save() will perform an UPDATE
+
+ $person = new Person();
+ $person->name_first = 'John';
+ $person->name_last = 'Lim';
+ $person->favorite_color = 'lavender';
+ $person->save(); // this save will perform an INSERT successfully
+
+ // load record where id=2 into a new ADOdb_Active_Record
+ $person2 = new Person();
+ $person2->Load('id=2');
+
+ $activeArr = $db->GetActiveRecordsClass($class = "Person",$table = "Persons","id=".$db->Param(0),array(2));
+ $person2 = $activeArr[0];
+ echo " Name (should be John): ",$person->name_first, " Affected Rows after delete=".$db->Affected_Rows()." ";
+ $db = NewADOConnection($dbType);
+ $dict = NewDataDictionary($db);
+
+ if (!$dict) continue;
+ $dict->debug = 1;
+
+ $opts = array('REPLACE','mysql' => 'ENGINE=INNODB', 'oci8' => 'TABLESPACE USERS');
+
+/* $flds = array(
+ array('id', 'I',
+ 'AUTO','KEY'),
+
+ array('name' => 'firstname', 'type' => 'varchar','size' => 30,
+ 'DEFAULT'=>'Joan'),
+
+ array('lastname','varchar',28,
+ 'DEFAULT'=>'Chen','key'),
+
+ array('averylonglongfieldname','X',1024,
+ 'NOTNULL','default' => 'test'),
+
+ array('price','N','7.2',
+ 'NOTNULL','default' => '0.00'),
+
+ array('MYDATE', 'D',
+ 'DEFDATE'),
+ array('TS','T',
+ 'DEFTIMESTAMP')
+ );*/
+
+ $flds = "
+ID I AUTO KEY,
+FIRSTNAME VARCHAR(30) DEFAULT 'Joan' INDEX idx_name,
+LASTNAME VARCHAR(28) DEFAULT 'Chen' key INDEX idx_name INDEX idx_lastname,
+averylonglongfieldname X(1024) DEFAULT 'test',
+price N(7.2) DEFAULT '0.00',
+MYDATE D DEFDATE INDEX idx_date,
+BIGFELLOW X NOTNULL,
+TS_SECS T DEFTIMESTAMP,
+TS_SUBSEC TS DEFTIMESTAMP
+";
+
+
+ $sqla = $dict->CreateDatabase('KUTU',array('postgres'=>"LOCATION='/u01/postdata'"));
+ $dict->SetSchema('KUTU');
+
+ $sqli = ($dict->CreateTableSQL('testtable',$flds, $opts));
+ $sqla = array_merge($sqla,$sqli);
+
+ $sqli = $dict->CreateIndexSQL('idx','testtable','price,firstname,lastname',array('BITMAP','FULLTEXT','CLUSTERED','HASH'));
+ $sqla = array_merge($sqla,$sqli);
+ $sqli = $dict->CreateIndexSQL('idx2','testtable','price,lastname');//,array('BITMAP','FULLTEXT','CLUSTERED'));
+ $sqla = array_merge($sqla,$sqli);
+
+ $addflds = array(array('height', 'F'),array('weight','F'));
+ $sqli = $dict->AddColumnSQL('testtable',$addflds);
+ $sqla = array_merge($sqla,$sqli);
+ $addflds = array(array('height', 'F','NOTNULL'),array('weight','F','NOTNULL'));
+ $sqli = $dict->AlterColumnSQL('testtable',$addflds);
+ $sqla = array_merge($sqla,$sqli);
+
+
+ printsqla($dbType,$sqla);
+
+ if (file_exists('d:\inetpub\wwwroot\php\phplens\adodb\adodb.inc.php'))
+ if ($dbType == 'mysqlt') {
+ $db->Connect('localhost', "root", "", "test");
+ $dict->SetSchema('');
+ $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
+ if ($sqla2) printsqla($dbType,$sqla2);
+ }
+ if ($dbType == 'postgres') {
+ if (@$db->Connect('localhost', "tester", "test", "test"));
+ $dict->SetSchema('');
+ $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
+ if ($sqla2) printsqla($dbType,$sqla2);
+ }
+
+ if ($dbType == 'odbc_mssql') {
+ $dsn = $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=localhost;Database=northwind;";
+ if (@$db->Connect($dsn, "sa", "natsoft", "test"));
+ $dict->SetSchema('');
+ $sqla2 = $dict->ChangeTableSQL('adoxyz',$flds);
+ if ($sqla2) printsqla($dbType,$sqla2);
+ }
+
+
+
+ adodb_pr($dict->databaseType);
+ printsqla($dbType, $dict->DropColumnSQL('table',array('my col','`col2_with_Quotes`','A_col3','col3(10)')));
+ printsqla($dbType, $dict->ChangeTableSQL('adoxyz','LASTNAME varchar(32)'));
+
+}
+
+function printsqla($dbType,$sqla)
+{
+ print " ';
+ echo $perf->HealthCheck();
+ echo($perf->SuspiciousSQL());
+ echo($perf->ExpensiveSQL());
+ echo($perf->InvalidSQL());
+ echo $perf->Tables();
+
+ echo " Error at $x";
+ break;
+ }
+ }
+}
+
+include_once('../adodb.inc.php');
+$db = NewADOConnection('postgres7');
+$db->PConnect('localhost','tester','test','test') || die("failed connection");
+
+$enc = "GIF89a%01%00%01%00%80%FF%00%C0%C0%C0%00%00%00%21%F9%04%01%00%00%00%00%2C%00%00%00%00%01%00%01%00%00%01%012%00%3Bt_clear.gif%0D";
+$val = rawurldecode($enc);
+
+$MAX = 1000;
+
+adodb_pr($db->ServerInfo());
+
+echo " ',$MAX,' times, with plan=',getmicrotime() - $t,' ',$MAX,' times, no plan=',getmicrotime() - $t,' ";
+echo "INSERTED: ", $val;
+echo " empty ";var_dump($v);
+}
+
+
+if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n");
+else echo "Count $i is correct";print_r($s);print "
";
+ }
+
+
+$serverURL = 'http://localhost/php/phplens/adodb/server.php';
+$testhttp = false;
+
+$sql1 = "insertz into products (productname) values ('testprod 1')";
+$sql2 = "insert into products (productname) values ('testprod 1')";
+$sql3 = "insert into products (productname) values ('testprod 2')";
+$sql4 = "delete from products where productid>80";
+$sql5 = 'select * from products';
+
+if ($testhttp) {
+ print "Client Driver TestsTest Error
";
+ $rs = send2server($serverURL,$sql1);
+ print_pre($rs);
+ print "
";
+
+ print "Test Insert
";
+
+ $rs = send2server($serverURL,$sql2);
+ print_pre($rs);
+ print "
";
+
+ print "Test Insert2
";
+
+ $rs = send2server($serverURL,$sql3);
+ print_pre($rs);
+ print "
";
+
+ print "Test Delete
";
+
+ $rs = send2server($serverURL,$sql4);
+ print_pre($rs);
+ print "
";
+
+
+ print "Test Select
";
+ $rs = send2server($serverURL,$sql5);
+ if ($rs) rs2html($rs);
+
+ print "
";
+}
+
+
+print "CLIENT Driver Tests
";
+$conn = ADONewConnection('csv');
+$conn->Connect($serverURL);
+$conn->debug = true;
+
+print "Bad SQL
";
+
+$rs = $conn->Execute($sql1);
+
+print "Insert SQL 1
";
+$rs = $conn->Execute($sql2);
+
+print "Insert SQL 2
";
+$rs = $conn->Execute($sql3);
+
+print "Select SQL
";
+$rs = $conn->Execute($sql5);
+if ($rs) rs2html($rs);
+
+print "Delete SQL
";
+$rs = $conn->Execute($sql4);
+
+print "Select SQL
";
+$rs = $conn->Execute($sql5);
+if ($rs) rs2html($rs);
+
+
+/* EXPECTED RESULTS FOR HTTP TEST:
+
+Test Insert
+http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
+
+adorecordset Object
+(
+ [dataProvider] => native
+ [fields] =>
+ [blobSize] => 64
+ [canSeek] =>
+ [EOF] => 1
+ [emptyTimeStamp] =>
+ [emptyDate] =>
+ [debug] =>
+ [timeToLive] => 0
+ [bind] =>
+ [_numOfRows] => -1
+ [_numOfFields] => 0
+ [_queryID] => 1
+ [_currentRow] => -1
+ [_closed] =>
+ [_inited] =>
+ [sql] => insert into products (productname) values ('testprod')
+ [affectedrows] => 1
+ [insertid] => 81
+)
+
+
+--------------------------------------------------------------------------------
+
+Test Insert2
+http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
+
+adorecordset Object
+(
+ [dataProvider] => native
+ [fields] =>
+ [blobSize] => 64
+ [canSeek] =>
+ [EOF] => 1
+ [emptyTimeStamp] =>
+ [emptyDate] =>
+ [debug] =>
+ [timeToLive] => 0
+ [bind] =>
+ [_numOfRows] => -1
+ [_numOfFields] => 0
+ [_queryID] => 1
+ [_currentRow] => -1
+ [_closed] =>
+ [_inited] =>
+ [sql] => insert into products (productname) values ('testprod')
+ [affectedrows] => 1
+ [insertid] => 82
+)
+
+
+--------------------------------------------------------------------------------
+
+Test Delete
+http://localhost/php/adodb/server.php?sql=delete+from+products+where+productid%3E80
+
+adorecordset Object
+(
+ [dataProvider] => native
+ [fields] =>
+ [blobSize] => 64
+ [canSeek] =>
+ [EOF] => 1
+ [emptyTimeStamp] =>
+ [emptyDate] =>
+ [debug] =>
+ [timeToLive] => 0
+ [bind] =>
+ [_numOfRows] => -1
+ [_numOfFields] => 0
+ [_queryID] => 1
+ [_currentRow] => -1
+ [_closed] =>
+ [_inited] =>
+ [sql] => delete from products where productid>80
+ [affectedrows] => 2
+ [insertid] => 0
+)
+
+[more stuff deleted]
+ .
+ .
+ .
+*/
diff --git a/vendor/adodb/adodb-php/tests/pdo.php b/vendor/adodb/adodb-php/tests/pdo.php
new file mode 100644
index 0000000..31ca596
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/pdo.php
@@ -0,0 +1,92 @@
+";
+try {
+ echo "New Connection\n";
+
+
+ $dsn = 'pdo_mysql://root:@localhost/northwind?persist';
+
+ if (!empty($dsn)) {
+ $DB = NewADOConnection($dsn) || die("CONNECT FAILED");
+ $connstr = $dsn;
+ } else {
+
+ $DB = NewADOConnection('pdo');
+
+ echo "Connect\n";
+
+ $u = ''; $p = '';
+ /*
+ $connstr = 'odbc:nwind';
+
+ $connstr = 'oci:';
+ $u = 'scott';
+ $p = 'natsoft';
+
+
+ $connstr ="sqlite:d:\inetpub\adodb\sqlite.db";
+ */
+
+ $connstr = "mysql:dbname=northwind";
+ $u = 'root';
+
+ $connstr = "pgsql:dbname=test";
+ $u = 'tester';
+ $p = 'test';
+
+ $DB->Connect($connstr,$u,$p) || die("CONNECT FAILED");
+
+ }
+
+ echo "connection string=$connstr\n Execute\n";
+
+ //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
+ $rs = $DB->Execute("select * from ADOXYZ where id<3");
+ if ($DB->ErrorNo()) echo "*** errno=".$DB->ErrorNo() . " ".($DB->ErrorMsg())."\n";
+
+
+ //print_r(get_class_methods($DB->_stmt));
+
+ if (!$rs) die("NO RS");
+
+ echo "Meta\n";
+ for ($i=0; $i < $rs->NumCols(); $i++) {
+ var_dump($rs->FetchField($i));
+ echo "
";
+ }
+
+ echo "FETCH\n";
+ $cnt = 0;
+ while (!$rs->EOF) {
+ adodb_pr($rs->fields);
+ $rs->MoveNext();
+ if ($cnt++ > 1000) break;
+ }
+
+ echo "
--------------------------------------------------------
\n\n\n";
+
+ $stmt = $DB->PrepareStmt("select * from ADOXYZ");
+
+ $rs = $stmt->Execute();
+ $cols = $stmt->NumCols(); // execute required
+
+ echo "COLS = $cols";
+ for($i=1;$i<=$cols;$i++) {
+ $v = $stmt->_stmt->getColumnMeta($i);
+ var_dump($v);
+ }
+
+ echo "e=".$stmt->ErrorNo() . " ".($stmt->ErrorMsg())."\n";
+ while ($arr = $rs->FetchRow()) {
+ adodb_pr($arr);
+ }
+ die("DONE\n");
+
+} catch (exception $e) {
+ echo "";
+ echo $e;
+ echo "
";
+}
diff --git a/vendor/adodb/adodb-php/tests/test-active-record.php b/vendor/adodb/adodb-php/tests/test-active-record.php
new file mode 100644
index 0000000..5947162
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-active-record.php
@@ -0,0 +1,140 @@
+= 5) {
+ include('../adodb-exceptions.inc.php');
+ echo "Exceptions included
";
+ }
+ }
+
+ $db = NewADOConnection('mysql://root@localhost/northwind?persist');
+ $db->debug=1;
+ ADOdb_Active_Record::SetDatabaseAdapter($db);
+
+
+ $db->Execute("CREATE TEMPORARY TABLE `persons` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `name_first` varchar(100) NOT NULL default '',
+ `name_last` varchar(100) NOT NULL default '',
+ `favorite_color` varchar(100) NOT NULL default '',
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM;
+ ");
+
+ $db->Execute("CREATE TEMPORARY TABLE `children` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `person_id` int(10) unsigned NOT NULL,
+ `name_first` varchar(100) NOT NULL default '',
+ `name_last` varchar(100) NOT NULL default '',
+ `favorite_pet` varchar(100) NOT NULL default '',
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM;
+ ");
+
+ class Person extends ADOdb_Active_Record{ function ret($v) {return $v;} }
+ $person = new Person();
+ ADOdb_Active_Record::$_quoteNames = '111';
+
+ echo "
Class (should be Person): ",get_class($person2),"
";
+
+ $db->Execute("insert into children (person_id,name_first,name_last) values (2,'Jill','Lim')");
+ $db->Execute("insert into children (person_id,name_first,name_last) values (2,'Joan','Lim')");
+ $db->Execute("insert into children (person_id,name_first,name_last) values (2,'JAMIE','Lim')");
+
+ $newperson2 = new Person();
+ $person2->HasMany('children','person_id');
+ $person2->Load('id=2');
+ $person2->name_last='green';
+ $c = $person2->children;
+ $person2->save();
+
+ if (is_array($c) && sizeof($c) == 3 && $c[0]->name_first=='Jill' && $c[1]->name_first=='Joan'
+ && $c[2]->name_first == 'JAMIE') echo "OK Loaded HasMany";
+ else {
+ var_dump($c);
+ echo "error loading hasMany should have 3 array elements Jill Joan Jamie
";
+ }
+
+ class Child extends ADOdb_Active_Record{};
+ $ch = new Child('children',array('id'));
+ $ch->BelongsTo('person','person_id','id');
+ $ch->Load('id=1');
+ if ($ch->name_first !== 'Jill') echo "error in Loading Child
";
+
+ $p = $ch->person;
+ if ($p->name_first != 'John') echo "Error loading belongsTo
";
+ else echo "OK loading BelongTo
";
+
+ $p->hasMany('children','person_id');
+ $p->LoadRelations('children', " Name_first like 'J%' order by id",1,2);
+ if (sizeof($p->children) == 2 && $p->children[1]->name_first == 'JAMIE') echo "OK LoadRelations
";
+ else echo "error LoadRelations
";
+
+ $db->Execute("CREATE TEMPORARY TABLE `persons2` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `name_first` varchar(100) NOT NULL default '',
+ `name_last` varchar(100) NOT NULL default '',
+ `favorite_color` varchar(100) default '',
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM;
+ ");
+
+ $p = new adodb_active_record('persons2');
+ $p->name_first = 'James';
+
+ $p->name_last = 'James';
+
+ $p->HasMany('children','person_id');
+ $p->children;
+ var_dump($p);
+ $p->Save();
diff --git a/vendor/adodb/adodb-php/tests/test-active-recs2.php b/vendor/adodb/adodb-php/tests/test-active-recs2.php
new file mode 100644
index 0000000..f5898fc
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-active-recs2.php
@@ -0,0 +1,76 @@
+Connect("localhost","tester","test","test");
+} else
+ $db = NewADOConnection('oci8://scott:natsoft@/');
+
+
+$arr = $db->ServerInfo();
+echo "$db->dataProvider: {$arr['description']}
";
+
+$arr = $db->GetActiveRecords('products',' productid<10');
+adodb_pr($arr);
+
+ADOdb_Active_Record::SetDatabaseAdapter($db);
+if (!$db) die('failed');
+
+
+
+
+$rec = new ADODB_Active_Record('photos');
+
+$rec = new ADODB_Active_Record('products');
+
+
+adodb_pr($rec->getAttributeNames());
+
+echo "
";
+
+
+$rec->load('productid=2');
+adodb_pr($rec);
+
+$db->debug=1;
+
+
+$rec->productname = 'Changie Chan'.rand();
+
+$rec->insert();
+$rec->update();
+
+$rec->productname = 'Changie Chan 99';
+$rec->replace();
+
+
+$rec2 = new ADODB_Active_Record('products');
+$rec->load('productid=3');
+$rec->save();
+
+$rec = new ADODB_Active_record('products');
+$rec->productname = 'John ActiveRec';
+$rec->notes = 22;
+#$rec->productid=0;
+$rec->discontinued=1;
+$rec->Save();
+$rec->supplierid=33;
+$rec->Save();
+$rec->discontinued=0;
+$rec->Save();
+$rec->Delete();
+
+echo "
";
+ }
+
+ class child extends ADOdb_Active_Record{};
+ ADODB_Active_Record::TableBelongsTo('children','person','person_id','id');
+ $ch = new Child('children',array('id'));
+
+ $ch->Load('id=1');
+ if ($ch->name_first !== 'Jill') echo "error in Loading Child
";
+
+ $p = $ch->person;
+ if (!$p || $p->name_first != 'John') echo "Error loading belongsTo
";
+ else echo "OK loading BelongTo
";
+
+ if ($p) {
+ #$p->HasMany('children','person_id'); ## this is affects all other instances of Person
+ $p->LoadRelations('children', 'order by id',1,2);
+ if (sizeof($p->children) == 2 && $p->children[1]->name_first == 'JAMIE') echo "OK LoadRelations
";
+ else {
+ var_dump($p->children);
+ echo "error LoadRelations
";
+ }
+
+ unset($p->children);
+ $p->LoadRelations('children', " name_first like 'J%' order by id",1,2);
+ }
+ if ($p)
+ foreach($p->children as $c) {
+ echo " Saving $c->name_first
";
+ $c->name_first .= ' K.';
+ $c->Save();
+ }
diff --git a/vendor/adodb/adodb-php/tests/test-active-relationsx.php b/vendor/adodb/adodb-php/tests/test-active-relationsx.php
new file mode 100644
index 0000000..0f28f72
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-active-relationsx.php
@@ -0,0 +1,418 @@
+\n", $txt);
+ echo $txt;
+ }
+
+ include_once('../adodb.inc.php');
+ include_once('../adodb-active-recordx.inc.php');
+
+
+ $db = NewADOConnection('mysql://root@localhost/test');
+ $db->debug=0;
+ ADOdb_Active_Record::SetDatabaseAdapter($db);
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("Preparing database using SQL queries (creating 'people', 'children')\n");
+
+ $db->Execute("DROP TABLE `people`");
+ $db->Execute("DROP TABLE `children`");
+ $db->Execute("DROP TABLE `artists`");
+ $db->Execute("DROP TABLE `songs`");
+
+ $db->Execute("CREATE TABLE `people` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `name_first` varchar(100) NOT NULL default '',
+ `name_last` varchar(100) NOT NULL default '',
+ `favorite_color` varchar(100) NOT NULL default '',
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM;
+ ");
+ $db->Execute("CREATE TABLE `children` (
+ `person_id` int(10) unsigned NOT NULL,
+ `name_first` varchar(100) NOT NULL default '',
+ `name_last` varchar(100) NOT NULL default '',
+ `favorite_pet` varchar(100) NOT NULL default '',
+ `id` int(10) unsigned NOT NULL auto_increment,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM;
+ ");
+
+ $db->Execute("CREATE TABLE `artists` (
+ `name` varchar(100) NOT NULL default '',
+ `artistuniqueid` int(10) unsigned NOT NULL auto_increment,
+ PRIMARY KEY (`artistuniqueid`)
+ ) ENGINE=MyISAM;
+ ");
+
+ $db->Execute("CREATE TABLE `songs` (
+ `name` varchar(100) NOT NULL default '',
+ `artistid` int(10) NOT NULL,
+ `recordid` int(10) unsigned NOT NULL auto_increment,
+ PRIMARY KEY (`recordid`)
+ ) ENGINE=MyISAM;
+ ");
+
+ $db->Execute("insert into children (person_id,name_first,name_last,favorite_pet) values (1,'Jill','Lim','tortoise')");
+ $db->Execute("insert into children (person_id,name_first,name_last) values (1,'Joan','Lim')");
+ $db->Execute("insert into children (person_id,name_first,name_last) values (1,'JAMIE','Lim')");
+
+ $db->Execute("insert into artists (artistuniqueid, name) values(1,'Elvis Costello')");
+ $db->Execute("insert into songs (recordid, name, artistid) values(1,'No Hiding Place', 1)");
+ $db->Execute("insert into songs (recordid, name, artistid) values(2,'American Gangster Time', 1)");
+
+ // This class _implicitely_ relies on the 'people' table (pluralized form of 'person')
+ class Person extends ADOdb_Active_Record
+ {
+ function __construct()
+ {
+ parent::__construct();
+ $this->hasMany('children');
+ }
+ }
+ // This class _implicitely_ relies on the 'children' table
+ class Child extends ADOdb_Active_Record
+ {
+ function __construct()
+ {
+ parent::__construct();
+ $this->belongsTo('person');
+ }
+ }
+ // This class _explicitely_ relies on the 'children' table and shares its metadata with Child
+ class Kid extends ADOdb_Active_Record
+ {
+ function __construct()
+ {
+ parent::__construct('children');
+ $this->belongsTo('person');
+ }
+ }
+ // This class _explicitely_ relies on the 'children' table but does not share its metadata
+ class Rugrat extends ADOdb_Active_Record
+ {
+ function __construct()
+ {
+ parent::__construct('children', false, false, array('new' => true));
+ }
+ }
+
+ class Artist extends ADOdb_Active_Record
+ {
+ function __construct()
+ {
+ parent::__construct('artists', array('artistuniqueid'));
+ $this->hasMany('songs', 'artistid');
+ }
+ }
+ class Song extends ADOdb_Active_Record
+ {
+ function __construct()
+ {
+ parent::__construct('songs', array('recordid'));
+ $this->belongsTo('artist', 'artistid');
+ }
+ }
+
+ ar_echo("Inserting person in 'people' table ('John Lim, he likes lavender')\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $person = new Person();
+ $person->name_first = 'John';
+ $person->name_last = 'Lim';
+ $person->favorite_color = 'lavender';
+ $person->save(); // this save will perform an INSERT successfully
+
+ $person = new Person();
+ $person->name_first = 'Lady';
+ $person->name_last = 'Cat';
+ $person->favorite_color = 'green';
+ $person->save();
+
+ $child = new Child();
+ $child->name_first = 'Fluffy';
+ $child->name_last = 'Cat';
+ $child->favorite_pet = 'Cat Lady';
+ $child->person_id = $person->id;
+ $child->save();
+
+ $child = new Child();
+ $child->name_first = 'Sun';
+ $child->name_last = 'Cat';
+ $child->favorite_pet = 'Cat Lady';
+ $child->person_id = $person->id;
+ $child->save();
+
+ $err_count = 0;
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("person->Find('id=1') [Lazy Method]\n");
+ ar_echo("person is loaded but its children will be loaded on-demand later on\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $person = new Person();
+ $people = $person->Find('id=1');
+ ar_echo((ar_assert(found($people, "'name_first' => 'John'"))) ? "[OK] Found John\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($people, "'favorite_pet' => 'tortoise'"))) ? "[OK] No relation yet\n" : "[!!] Found relation when I shouldn't\n");
+ ar_echo("\n-- Lazily Loading Children:\n\n");
+ foreach($people as $aperson)
+ {
+ foreach($aperson->children as $achild)
+ {
+ if($achild->name_first);
+ }
+ }
+ ar_echo((ar_assert(found($people, "'favorite_pet' => 'tortoise'"))) ? "[OK] Found relation: child\n" : "[!!] Missing relation: child\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'Joan'"))) ? "[OK] Found Joan\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'JAMIE'"))) ? "[OK] Found JAMIE\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("person->Find('id=1' ... ADODB_WORK_AR) [Worker Method]\n");
+ ar_echo("person is loaded, and so are its children\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $person = new Person();
+ $people = $person->Find('id=1', false, false, array('loading' => ADODB_WORK_AR));
+ ar_echo((ar_assert(found($people, "'name_first' => 'John'"))) ? "[OK] Found John\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'favorite_pet' => 'tortoise'"))) ? "[OK] Found relation: child\n" : "[!!] Missing relation: child\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'Joan'"))) ? "[OK] Found Joan\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'JAMIE'"))) ? "[OK] Found JAMIE\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("person->Find('id=1' ... ADODB_JOIN_AR) [Join Method]\n");
+ ar_echo("person and its children are loaded using a single query\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $person = new Person();
+ // When I specifically ask for a join, I have to specify which table id I am looking up
+ // otherwise the SQL parser will wonder which table's id that would be.
+ $people = $person->Find('people.id=1', false, false, array('loading' => ADODB_JOIN_AR));
+ ar_echo((ar_assert(found($people, "'name_first' => 'John'"))) ? "[OK] Found John\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'favorite_pet' => 'tortoise'"))) ? "[OK] Found relation: child\n" : "[!!] Missing relation: child\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'Joan'"))) ? "[OK] Found Joan\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'JAMIE'"))) ? "[OK] Found JAMIE\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("person->Load('people.id=1') [Join Method]\n");
+ ar_echo("Load() always uses the join method since it returns only one row\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $person = new Person();
+ // Under the hood, Load(), since it returns only one row, always perform a join
+ // Therefore we need to clarify which id we are talking about.
+ $person->Load('people.id=1');
+ ar_echo((ar_assert(found($person, "'name_first' => 'John'"))) ? "[OK] Found John\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($person, "'favorite_pet' => 'tortoise'"))) ? "[OK] Found relation: child\n" : "[!!] Missing relation: child\n");
+ ar_echo((ar_assert(found($person, "'name_first' => 'Joan'"))) ? "[OK] Found Joan\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($person, "'name_first' => 'JAMIE'"))) ? "[OK] Found JAMIE\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("child->Load('children.id=1') [Join Method]\n");
+ ar_echo("We are now loading from the 'children' table, not from 'people'\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $child = new Child();
+ $child->Load('children.id=1');
+ ar_echo((ar_assert(found($child, "'name_first' => 'Jill'"))) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($child, "'favorite_color' => 'lavender'"))) ? "[OK] Found relation: person\n" : "[!!] Missing relation: person\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("child->Find('children.id=1' ... ADODB_WORK_AR) [Worker Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $child = new Child();
+ $children = $child->Find('id=1', false, false, array('loading' => ADODB_WORK_AR));
+ ar_echo((ar_assert(found($children, "'name_first' => 'Jill'"))) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($children, "'favorite_color' => 'lavender'"))) ? "[OK] Found relation: person\n" : "[!!] Missing relation: person\n");
+ ar_echo((ar_assert(notfound($children, "'name_first' => 'Joan'"))) ? "[OK] No Joan relation\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($children, "'name_first' => 'JAMIE'"))) ? "[OK] No JAMIE relation\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("kid->Find('children.id=1' ... ADODB_WORK_AR) [Worker Method]\n");
+ ar_echo("Where we see that kid shares relationships with child because they are stored\n");
+ ar_echo("in the common table's metadata structure.\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $kid = new Kid('children');
+ $kids = $kid->Find('children.id=1', false, false, array('loading' => ADODB_WORK_AR));
+ ar_echo((ar_assert(found($kids, "'name_first' => 'Jill'"))) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($kids, "'favorite_color' => 'lavender'"))) ? "[OK] Found relation: person\n" : "[!!] Missing relation: person\n");
+ ar_echo((ar_assert(notfound($kids, "'name_first' => 'Joan'"))) ? "[OK] No Joan relation\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($kids, "'name_first' => 'JAMIE'"))) ? "[OK] No JAMIE relation\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("kid->Find('children.id=1' ... ADODB_LAZY_AR) [Lazy Method]\n");
+ ar_echo("Of course, lazy loading also retrieve medata information...\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $kid = new Kid('children');
+ $kids = $kid->Find('children.id=1', false, false, array('loading' => ADODB_LAZY_AR));
+ ar_echo((ar_assert(found($kids, "'name_first' => 'Jill'"))) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($kids, "'favorite_color' => 'lavender'"))) ? "[OK] No relation yet\n" : "[!!] Found relation when I shouldn't\n");
+ ar_echo("\n-- Lazily Loading People:\n\n");
+ foreach($kids as $akid)
+ {
+ if($akid->person);
+ }
+ ar_echo((ar_assert(found($kids, "'favorite_color' => 'lavender'"))) ? "[OK] Found relation: person\n" : "[!!] Missing relation: person\n");
+ ar_echo((ar_assert(notfound($kids, "'name_first' => 'Joan'"))) ? "[OK] No Joan relation\n" : "[!!] Found relation when I shouldn't\n");
+ ar_echo((ar_assert(notfound($kids, "'name_first' => 'JAMIE'"))) ? "[OK] No JAMIE relation\n" : "[!!] Found relation when I shouldn't\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("rugrat->Find('children.id=1' ... ADODB_WORK_AR) [Worker Method]\n");
+ ar_echo("In rugrat's constructor it is specified that\nit must forget any existing relation\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $rugrat = new Rugrat('children');
+ $rugrats = $rugrat->Find('children.id=1', false, false, array('loading' => ADODB_WORK_AR));
+ ar_echo((ar_assert(found($rugrats, "'name_first' => 'Jill'"))) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($rugrats, "'favorite_color' => 'lavender'"))) ? "[OK] No relation found\n" : "[!!] Found relation when I shouldn't\n");
+ ar_echo((ar_assert(notfound($rugrats, "'name_first' => 'Joan'"))) ? "[OK] No Joan relation\n" : "[!!] Found relation when I shouldn't\n");
+ ar_echo((ar_assert(notfound($rugrats, "'name_first' => 'JAMIE'"))) ? "[OK] No JAMIE relation\n" : "[!!] Found relation when I shouldn't\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("kid->Find('children.id=1' ... ADODB_WORK_AR) [Worker Method]\n");
+ ar_echo("Note how only rugrat forgot its relations - kid is fine.\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $kid = new Kid('children');
+ $kids = $kid->Find('children.id=1', false, false, array('loading' => ADODB_WORK_AR));
+ ar_echo((ar_assert(found($kids, "'name_first' => 'Jill'"))) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($kids, "'favorite_color' => 'lavender'"))) ? "[OK] I did not forget relation: person\n" : "[!!] I should not have forgotten relation: person\n");
+ ar_echo((ar_assert(notfound($kids, "'name_first' => 'Joan'"))) ? "[OK] No Joan relation\n" : "[!!] Found relation when I shouldn't\n");
+ ar_echo((ar_assert(notfound($kids, "'name_first' => 'JAMIE'"))) ? "[OK] No JAMIE relation\n" : "[!!] Found relation when I shouldn't\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("rugrat->Find('children.id=1' ... ADODB_WORK_AR) [Worker Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $rugrat = new Rugrat('children');
+ $rugrats = $rugrat->Find('children.id=1', false, false, array('loading' => ADODB_WORK_AR));
+ $arugrat = $rugrats[0];
+ ar_echo((ar_assert(found($arugrat, "'name_first' => 'Jill'"))) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($arugrat, "'favorite_color' => 'lavender'"))) ? "[OK] No relation yet\n" : "[!!] Found relation when I shouldn't\n");
+
+ ar_echo("\n-- Loading relations:\n\n");
+ $arugrat->belongsTo('person');
+ $arugrat->LoadRelations('person', 'order by id', 0, 2);
+ ar_echo((ar_assert(found($arugrat, "'favorite_color' => 'lavender'"))) ? "[OK] Found relation: person\n" : "[!!] Missing relation: person\n");
+ ar_echo((ar_assert(found($arugrat, "'name_first' => 'Jill'"))) ? "[OK] Found Jill\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($arugrat, "'name_first' => 'Joan'"))) ? "[OK] No Joan relation\n" : "[!!] Found relation when I shouldn't\n");
+ ar_echo((ar_assert(notfound($arugrat, "'name_first' => 'JAMIE'"))) ? "[OK] No Joan relation\n" : "[!!] Found relation when I shouldn't\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("person->Find('1=1') [Lazy Method]\n");
+ ar_echo("And now for our finale...\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $person = new Person();
+ $people = $person->Find('1=1', false, false, array('loading' => ADODB_LAZY_AR));
+ ar_echo((ar_assert(found($people, "'name_first' => 'John'"))) ? "[OK] Found John\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($people, "'favorite_pet' => 'tortoise'"))) ? "[OK] No relation yet\n" : "[!!] Found relation when I shouldn't\n");
+ ar_echo((ar_assert(notfound($people, "'name_first' => 'Fluffy'"))) ? "[OK] No Fluffy yet\n" : "[!!] Found Fluffy relation when I shouldn't\n");
+ ar_echo("\n-- Lazily Loading Everybody:\n\n");
+ foreach($people as $aperson)
+ {
+ foreach($aperson->children as $achild)
+ {
+ if($achild->name_first);
+ }
+ }
+ ar_echo((ar_assert(found($people, "'favorite_pet' => 'tortoise'"))) ? "[OK] Found relation: child\n" : "[!!] Missing relation: child\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'Joan'"))) ? "[OK] Found Joan\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'JAMIE'"))) ? "[OK] Found JAMIE\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'Lady'"))) ? "[OK] Found Cat Lady\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'Fluffy'"))) ? "[OK] Found Fluffy\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($people, "'name_first' => 'Sun'"))) ? "[OK] Found Sun\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("artist->Load('artistuniqueid=1') [Join Method]\n");
+ ar_echo("Yes, we are dabbling in the musical field now..\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $artist = new Artist();
+ $artist->Load('artistuniqueid=1');
+ ar_echo((ar_assert(found($artist, "'name' => 'Elvis Costello'"))) ? "[OK] Found Elvis Costello\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($artist, "'name' => 'No Hiding Place'"))) ? "[OK] Found relation: song\n" : "[!!] Missing relation: song\n");
+
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("song->Load('recordid=1') [Join Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $song = new Song();
+ $song->Load('recordid=1');
+ ar_echo((ar_assert(found($song, "'name' => 'No Hiding Place'"))) ? "[OK] Found song\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("artist->Find('artistuniqueid=1' ... ADODB_JOIN_AR) [Join Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $artist = new Artist();
+ $artists = $artist->Find('artistuniqueid=1', false, false, array('loading' => ADODB_JOIN_AR));
+ ar_echo((ar_assert(found($artists, "'name' => 'Elvis Costello'"))) ? "[OK] Found Elvis Costello\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($artists, "'name' => 'No Hiding Place'"))) ? "[OK] Found relation: song\n" : "[!!] Missing relation: song\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("song->Find('recordid=1' ... ADODB_JOIN_AR) [Join Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $song = new Song();
+ $songs = $song->Find('recordid=1', false, false, array('loading' => ADODB_JOIN_AR));
+ ar_echo((ar_assert(found($songs, "'name' => 'No Hiding Place'"))) ? "[OK] Found song\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("artist->Find('artistuniqueid=1' ... ADODB_WORK_AR) [Work Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $artist = new Artist();
+ $artists = $artist->Find('artistuniqueid=1', false, false, array('loading' => ADODB_WORK_AR));
+ ar_echo((ar_assert(found($artists, "'name' => 'Elvis Costello'"))) ? "[OK] Found Elvis Costello\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(found($artists, "'name' => 'No Hiding Place'"))) ? "[OK] Found relation: song\n" : "[!!] Missing relation: song\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("song->Find('recordid=1' ... ADODB_JOIN_AR) [Join Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $song = new Song();
+ $songs = $song->Find('recordid=1', false, false, array('loading' => ADODB_WORK_AR));
+ ar_echo((ar_assert(found($songs, "'name' => 'No Hiding Place'"))) ? "[OK] Found song\n" : "[!!] Find failed\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("artist->Find('artistuniqueid=1' ... ADODB_LAZY_AR) [Lazy Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $artist = new Artist();
+ $artists = $artist->Find('artistuniqueid=1', false, false, array('loading' => ADODB_LAZY_AR));
+ ar_echo((ar_assert(found($artists, "'name' => 'Elvis Costello'"))) ? "[OK] Found Elvis Costello\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($artists, "'name' => 'No Hiding Place'"))) ? "[OK] No relation yet\n" : "[!!] Found relation when I shouldn't\n");
+ foreach($artists as $anartist)
+ {
+ foreach($anartist->songs as $asong)
+ {
+ if($asong->name);
+ }
+ }
+ ar_echo((ar_assert(found($artists, "'name' => 'No Hiding Place'"))) ? "[OK] Found relation: song\n" : "[!!] Missing relation: song\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("song->Find('recordid=1' ... ADODB_LAZY_AR) [Lazy Method]\n");
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
+ $song = new Song();
+ $songs = $song->Find('recordid=1', false, false, array('loading' => ADODB_LAZY_AR));
+ ar_echo((ar_assert(found($songs, "'name' => 'No Hiding Place'"))) ? "[OK] Found song\n" : "[!!] Find failed\n");
+ ar_echo((ar_assert(notfound($songs, "'name' => 'Elvis Costello'"))) ? "[OK] No relation yet\n" : "[!!] Found relation when I shouldn't\n");
+ foreach($songs as $asong)
+ {
+ if($asong->artist);
+ }
+ ar_echo((ar_assert(found($songs, "'name' => 'Elvis Costello'"))) ? "[OK] Found relation: artist\n" : "[!!] Missing relation: artist\n");
+
+ ar_echo("\n\n-------------------------------------------------------------------------------------------------------------------\n");
+ ar_echo("Test suite complete. " . (($err_count > 0) ? "$err_count errors found.\n" : "Success.\n"));
+ ar_echo("-------------------------------------------------------------------------------------------------------------------\n");
diff --git a/vendor/adodb/adodb-php/tests/test-datadict.php b/vendor/adodb/adodb-php/tests/test-datadict.php
new file mode 100644
index 0000000..9793f44
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-datadict.php
@@ -0,0 +1,251 @@
+$dbType";
+ //print_r($dict->MetaTables());
+ foreach($sqla as $s) {
+ $s = htmlspecialchars($s);
+ print "$s;\n";
+ if ($dbType == 'oci8') print "/\n";
+ }
+ print "
";
+}
+
+/***
+
+Generated SQL:
+
+mysql
+
+CREATE DATABASE KUTU;
+DROP TABLE KUTU.testtable;
+CREATE TABLE KUTU.testtable (
+id INTEGER NOT NULL AUTO_INCREMENT,
+firstname VARCHAR(30) DEFAULT 'Joan',
+lastname VARCHAR(28) NOT NULL DEFAULT 'Chen',
+averylonglongfieldname LONGTEXT NOT NULL,
+price NUMERIC(7,2) NOT NULL DEFAULT 0.00,
+MYDATE DATE DEFAULT CURDATE(),
+ PRIMARY KEY (id, lastname)
+)TYPE=ISAM;
+CREATE FULLTEXT INDEX idx ON KUTU.testtable (firstname,lastname);
+CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
+ALTER TABLE KUTU.testtable ADD height DOUBLE;
+ALTER TABLE KUTU.testtable ADD weight DOUBLE;
+ALTER TABLE KUTU.testtable MODIFY COLUMN height DOUBLE NOT NULL;
+ALTER TABLE KUTU.testtable MODIFY COLUMN weight DOUBLE NOT NULL;
+
+
+--------------------------------------------------------------------------------
+
+oci8
+
+CREATE USER KUTU IDENTIFIED BY tiger;
+/
+GRANT CREATE SESSION, CREATE TABLE,UNLIMITED TABLESPACE,CREATE SEQUENCE TO KUTU;
+/
+DROP TABLE KUTU.testtable CASCADE CONSTRAINTS;
+/
+CREATE TABLE KUTU.testtable (
+id NUMBER(16) NOT NULL,
+firstname VARCHAR(30) DEFAULT 'Joan',
+lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
+averylonglongfieldname CLOB NOT NULL,
+price NUMBER(7,2) DEFAULT 0.00 NOT NULL,
+MYDATE DATE DEFAULT TRUNC(SYSDATE),
+ PRIMARY KEY (id, lastname)
+)TABLESPACE USERS;
+/
+DROP SEQUENCE KUTU.SEQ_testtable;
+/
+CREATE SEQUENCE KUTU.SEQ_testtable;
+/
+CREATE OR REPLACE TRIGGER KUTU.TRIG_SEQ_testtable BEFORE insert ON KUTU.testtable
+ FOR EACH ROW
+ BEGIN
+ select KUTU.SEQ_testtable.nextval into :new.id from dual;
+ END;
+/
+CREATE BITMAP INDEX idx ON KUTU.testtable (firstname,lastname);
+/
+CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
+/
+ALTER TABLE testtable ADD (
+ height NUMBER,
+ weight NUMBER);
+/
+ALTER TABLE testtable MODIFY(
+ height NUMBER NOT NULL,
+ weight NUMBER NOT NULL);
+/
+
+
+--------------------------------------------------------------------------------
+
+postgres
+AlterColumnSQL not supported for PostgreSQL
+
+
+CREATE DATABASE KUTU LOCATION='/u01/postdata';
+DROP TABLE KUTU.testtable;
+CREATE TABLE KUTU.testtable (
+id SERIAL,
+firstname VARCHAR(30) DEFAULT 'Joan',
+lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
+averylonglongfieldname TEXT NOT NULL,
+price NUMERIC(7,2) DEFAULT 0.00 NOT NULL,
+MYDATE DATE DEFAULT CURRENT_DATE,
+ PRIMARY KEY (id, lastname)
+);
+CREATE INDEX idx ON KUTU.testtable USING HASH (firstname,lastname);
+CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
+ALTER TABLE KUTU.testtable ADD height FLOAT8;
+ALTER TABLE KUTU.testtable ADD weight FLOAT8;
+
+
+--------------------------------------------------------------------------------
+
+odbc_mssql
+
+CREATE DATABASE KUTU;
+DROP TABLE KUTU.testtable;
+CREATE TABLE KUTU.testtable (
+id INT IDENTITY(1,1) NOT NULL,
+firstname VARCHAR(30) DEFAULT 'Joan',
+lastname VARCHAR(28) DEFAULT 'Chen' NOT NULL,
+averylonglongfieldname TEXT NOT NULL,
+price NUMERIC(7,2) DEFAULT 0.00 NOT NULL,
+MYDATE DATETIME DEFAULT GetDate(),
+ PRIMARY KEY (id, lastname)
+);
+CREATE CLUSTERED INDEX idx ON KUTU.testtable (firstname,lastname);
+CREATE INDEX idx2 ON KUTU.testtable (price,lastname);
+ALTER TABLE KUTU.testtable ADD
+ height REAL,
+ weight REAL;
+ALTER TABLE KUTU.testtable ALTER COLUMN height REAL NOT NULL;
+ALTER TABLE KUTU.testtable ALTER COLUMN weight REAL NOT NULL;
+
+
+--------------------------------------------------------------------------------
+*/
+
+
+echo "Test XML Schema
";
+$ff = file('xmlschema.xml');
+echo "";
+foreach($ff as $xml) echo htmlspecialchars($xml);
+echo "
";
+include_once('test-xmlschema.php');
diff --git a/vendor/adodb/adodb-php/tests/test-perf.php b/vendor/adodb/adodb-php/tests/test-perf.php
new file mode 100644
index 0000000..62465be
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-perf.php
@@ -0,0 +1,48 @@
+ $v) {
+ if (strncmp($k,'test',4) == 0) $_SESSION['_db'] = $k;
+ }
+}
+
+if (isset($_SESSION['_db'])) {
+ $_db = $_SESSION['_db'];
+ $_GET[$_db] = 1;
+ $$_db = 1;
+}
+
+echo "Performance Monitoring
";
+include_once('testdatabases.inc.php');
+
+
+function testdb($db)
+{
+ if (!$db) return;
+ echo "";print_r($db->ServerInfo()); echo " user=".$db->user."";
+
+ $perf = NewPerfMonitor($db);
+
+ # unit tests
+ if (0) {
+ //$DB->debug=1;
+ echo "Data Cache Size=".$perf->DBParameter('data cache size').'";
+ echo $perf->HealthCheckCLI();
+ $perf->Poll(3);
+ die();
+ }
+
+ if ($perf) $perf->UI(3);
+}
diff --git a/vendor/adodb/adodb-php/tests/test-pgblob.php b/vendor/adodb/adodb-php/tests/test-pgblob.php
new file mode 100644
index 0000000..3add99e
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-pgblob.php
@@ -0,0 +1,86 @@
+Param(false);
+ $x = (rand() % 10) + 1;
+ $db->debug= ($i==1);
+ $id = $db->GetOne($sql,
+ array('Z%','Z%',$x));
+ if($id != $offset+$x) {
+ print "
Testing PREPARE/EXECUTE PLAN
";
+
+
+$db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database
+$t = getmicrotime();
+doloop();
+echo 'Testing UPDATEBLOB
";
+$db->debug=1;
+
+### TEST BEGINS
+
+$db->Execute("insert into photos (id,name) values(9999,'dot.gif')");
+$db->UpdateBlob('photos','photo',$val,'id=9999');
+$v = $db->GetOne('select photo from photos where id=9999');
+
+
+### CLEANUP
+
+$db->Execute("delete from photos where id=9999");
+
+### VALIDATION
+
+if ($v !== $val) echo "*** ERROR: Inserted value does not match downloaded val";
+else echo "*** OK: Passed";
+
+echo "";
+echo "INSERTED: ", $enc;
+echo "
";
+echo"RETURNED: ", rawurlencode($v);
+echo "
";
+echo "RETURNED: ", $v;
diff --git a/vendor/adodb/adodb-php/tests/test-php5.php b/vendor/adodb/adodb-php/tests/test-php5.php
new file mode 100644
index 0000000..4fe7ed8
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-php5.php
@@ -0,0 +1,116 @@
+PHP ".PHP_VERSION."\n";
+try {
+
+$dbt = 'oci8po';
+
+try {
+switch($dbt) {
+case 'oci8po':
+ $db = NewADOConnection("oci8po");
+
+ $db->Connect('localhost','scott','natsoft','sherkhan');
+ break;
+default:
+case 'mysql':
+ $db = NewADOConnection("mysql");
+ $db->Connect('localhost','root','','northwind');
+ break;
+
+case 'mysqli':
+ $db = NewADOConnection("mysqli://root:@localhost/northwind");
+ //$db->Connect('localhost','root','','test');
+ break;
+}
+} catch (exception $e){
+ echo "Connect Failed";
+ adodb_pr($e);
+ die();
+}
+
+$db->debug=1;
+
+$cnt = $db->GetOne("select count(*) from adoxyz where ?
Foreach Iterator Test (rand=".rand().")
";
+$i = 0;
+foreach($rs as $v) {
+ $i += 1;
+ echo "rec $i: "; $s1 = adodb_pr($v,true); $s2 = adodb_pr($rs->fields,true);
+ if ($s1 != $s2 && !empty($v)) {adodb_pr($s1); adodb_pr($s2);}
+ else echo "passed
";
+ flush();
+}
+
+$rs = new ADORecordSet_empty();
+foreach($rs as $v) {
+ echo "
";
+
+$rs = $db->Execute("select bad from badder");
+
+} catch (exception $e) {
+ adodb_pr($e);
+ echo "adodb_backtrace:
\n";
+ $e = adodb_backtrace($e->gettrace());
+}
+
+$rs = $db->Execute("select distinct id, firstname,lastname from adoxyz order by id");
+echo "Result=\n",$rs,"
Successfully created City()
";
+ #var_dump($a->GetPrimaryKeys());
+ $a->city = 'Kuala Lumpur';
+ $a->Save();
+ $a->Update();
+ #$a->SetPrimaryKeys(array('city'));
+ $a->country = "M'sia";
+ $a->save();
+ $a->Delete();
+} catch(exception $e){
+ echo $e->getMessage();
+}
+
+//include_once("test-active-record.php");
diff --git a/vendor/adodb/adodb-php/tests/test-xmlschema.php b/vendor/adodb/adodb-php/tests/test-xmlschema.php
new file mode 100644
index 0000000..c56cfec
--- /dev/null
+++ b/vendor/adodb/adodb-php/tests/test-xmlschema.php
@@ -0,0 +1,53 @@
+Connect( 'localhost', 'root', '', 'test' ) || die('fail connect1');
+
+// To create a schema object and build the query array.
+$schema = new adoSchema( $db );
+
+// To upgrade an existing schema object, use the following
+// To upgrade an existing database to the provided schema,
+// uncomment the following line:
+#$schema->upgradeSchema();
+
+print "SQL to build xmlschema.xml:\n
"; +// Build the SQL array +$sql = $schema->ParseSchema( "xmlschema.xml" ); + +var_dump( $sql ); +print "\n"; + +// Execute the SQL on the database +//$result = $schema->ExecuteSchema( $sql ); + +// Finally, clean up after the XML parser +// (PHP won't do this for you!) +//$schema->Destroy(); + + + +print "SQL to build xmlschema-mssql.xml:\n
"; + +$db2 = ADONewConnection('mssql'); +$db2->Connect('','adodb','natsoft','northwind') || die("Fail 2"); + +$db2->Execute("drop table simple_table"); + +$schema = new adoSchema( $db2 ); +$sql = $schema->ParseSchema( "xmlschema-mssql.xml" ); + +print_r( $sql ); +print "\n"; + +$db2->debug=1; + +foreach ($sql as $s) +$db2->Execute($s); diff --git a/vendor/adodb/adodb-php/tests/test.php b/vendor/adodb/adodb-php/tests/test.php new file mode 100644 index 0000000..030e85c --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test.php @@ -0,0 +1,1781 @@ +$msg
White space detected in adodb-$conn.inc.php or include file...
"; + //die(); + } +} + +function do_strtolower(&$arr) +{ + foreach($arr as $k => $v) { + if (is_object($v)) $arr[$k] = adodb_pr($v,true); + else $arr[$k] = strtolower($v); + } +} + + +function CountExecs($db, $sql, $inputarray) +{ +global $EXECS; $EXECS++; +} + +function CountCachedExecs($db, $secs2cache, $sql, $inputarray) +{ +global $CACHED; $CACHED++; +} + +// the table creation code is specific to the database, so we allow the user +// to define their own table creation stuff + +function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)") +{ +GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE,$ADODB_COUNTRECS; + + //adodb_pr($db); + +?> +Close(); + if ($rs2) $rs2->Close(); + if ($rs) $rs->Close(); + $db->Close(); + + if ($db->transCnt != 0) Err("Error in transCnt=$db->transCnt (should be 0)"); + + + printf("Total queries=%d; total cached=%d
",$EXECS+$CACHED, $CACHED); + flush(); +} + +function adodb_test_err($dbms, $fn, $errno, $errmsg, $p1=false, $p2=false) +{ +global $TESTERRS,$ERRNO; + + $ERRNO = $errno; + $TESTERRS += 1; + print "** $dbms ($fn): errno=$errno errmsg=$errmsg ($p1,$p2)"; +} +if (sizeof($_GET) == 0) $testmysql = true; + + +foreach($_GET as $k=>$v) { + // XSS protection (see Github issue #274) - only set variables for + // expected get parameters used in testdatabases.inc.php + if(preg_match('/^(test|no)\w+$/', $k)) { + $$k = $v; + } +} + +?> + +
+vers=",ADOConnection::Version(); + + + +?> +
ADODB Database Library (c) 2000-2014 John Lim. All rights reserved. Released under BSD and LGPL, PHP .
+ + diff --git a/vendor/adodb/adodb-php/tests/test2.php b/vendor/adodb/adodb-php/tests/test2.php new file mode 100644 index 0000000..eb3b025 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test2.php @@ -0,0 +1,25 @@ +debug=1; + $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; + $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;' + . 'DATA SOURCE=' . $access . ';'; + + echo "PHP ",PHP_VERSION,"
"; + + $db->Connect($myDSN) || die('fail'); + + print_r($db->ServerInfo()); + + try { + $rs = $db->Execute("select $db->sysTimeStamp,* from adoxyz where id>02xx"); + print_r($rs->fields); + } catch(exception $e) { + print_r($e); + echo "Date m/d/Y =",$db->UserDate($rs->fields[4],'m/d/Y'); + } diff --git a/vendor/adodb/adodb-php/tests/test3.php b/vendor/adodb/adodb-php/tests/test3.php new file mode 100644 index 0000000..7fe6739 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test3.php @@ -0,0 +1,44 @@ +Connect('','scott','natsoft'); +$db->debug=1; + +$cnt = $db->GetOne("select count(*) from adoxyz"); +$rs = $db->Execute("select * from adoxyz order by id"); + +$i = 0; +foreach($rs as $k => $v) { + $i += 1; + echo $k; adodb_pr($v); + flush(); +} + +if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n"); + + + +$rs = $db->Execute("select bad from badder"); + +} catch (exception $e) { + adodb_pr($e); + $e = adodb_backtrace($e->trace); +} diff --git a/vendor/adodb/adodb-php/tests/test4.php b/vendor/adodb/adodb-php/tests/test4.php new file mode 100644 index 0000000..843094b --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test4.php @@ -0,0 +1,144 @@ +PConnect("", "sa", "natsoft", "northwind"); // connect to MySQL, testdb + +$conn = ADONewConnection("mysql"); // create a connection +$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb + + +#$conn = ADONewConnection('oci8po'); +#$conn->Connect('','scott','natsoft'); + +if (PHP_VERSION >= 5) { + $connstr = "mysql:dbname=northwind"; + $u = 'root';$p=''; + $conn = ADONewConnection('pdo'); + $conn->Connect($connstr, $u, $p); +} +//$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + + +$conn->debug=1; +$conn->Execute("delete from adoxyz where lastname like 'Smi%'"); + +$rs = $conn->Execute($sql); // Execute the query and get the empty recordset +$record = array(); // Initialize an array to hold the record data to insert + +if (strpos($conn->databaseType,'mysql')===false) $record['id'] = 751; +$record["firstname"] = 'Jann'; +$record["lastname"] = "Smitts"; +$record["created"] = time(); + +$insertSQL = $conn->GetInsertSQL($rs, $record); +$conn->Execute($insertSQL); // Insert the record into the database + +if (strpos($conn->databaseType,'mysql')===false) $record['id'] = 752; +// Set the values for the fields in the record +$record["firstname"] = 'anull'; +$record["lastname"] = "Smith\$@//"; +$record["created"] = time(); + +if (isset($_GET['f'])) $ADODB_FORCE_TYPE = $_GET['f']; + +//$record["id"] = -1; + +// Pass the empty recordset and the array containing the data to insert +// into the GetInsertSQL function. The function will process the data and return +// a fully formatted insert sql statement. +$insertSQL = $conn->GetInsertSQL($rs, $record); +$conn->Execute($insertSQL); // Insert the record into the database + + + +$insertSQL2 = $conn->GetInsertSQL($table='ADOXYZ', $record); +if ($insertSQL != $insertSQL2) echo "
Walt's new stuff failed: $insertSQL2
"; +//========================== +// This code tests an update + +$sql = " +SELECT * +FROM ADOXYZ WHERE lastname=".$conn->Param('var'). " ORDER BY 1"; +// Select a record to update + +$varr = array('var'=>$record['lastname'].''); +$rs = $conn->Execute($sql,$varr); // Execute the query and get the existing record to update +if (!$rs || $rs->EOF) print "No record found!
"; + +$record = array(); // Initialize an array to hold the record data to update + + +// Set the values for the fields in the record +$record["firstName"] = "Caroline".rand(); +//$record["lasTname"] = ""; // Update Caroline's lastname from Miranda to Smith +$record["creAted"] = '2002-12-'.(rand()%30+1); +$record['num'] = ''; +// Pass the single record recordset and the array containing the data to update +// into the GetUpdateSQL function. The function will process the data and return +// a fully formatted update sql statement. +// If the data has not changed, no recordset is returned + +$updateSQL = $conn->GetUpdateSQL($rs, $record); +$conn->Execute($updateSQL,$varr); // Update the record in the database +if ($conn->Affected_Rows() != 1)print "Error1 : Rows Affected=".$conn->Affected_Rows().", should be 1
"; + +$record["firstName"] = "Caroline".rand(); +$record["lasTname"] = "Smithy Jones"; // Update Caroline's lastname from Miranda to Smith +$record["creAted"] = '2002-12-'.(rand()%30+1); +$record['num'] = 331; +$updateSQL = $conn->GetUpdateSQL($rs, $record); +$conn->Execute($updateSQL,$varr); // Update the record in the database +if ($conn->Affected_Rows() != 1)print "Error 2: Rows Affected=".$conn->Affected_Rows().", should be 1
"; + +$rs = $conn->Execute("select * from ADOXYZ where lastname like 'Sm%'"); +//adodb_pr($rs); +rs2html($rs); + +$record["firstName"] = "Carol-new-".rand(); +$record["lasTname"] = "Smithy"; // Update Caroline's lastname from Miranda to Smith +$record["creAted"] = '2002-12-'.(rand()%30+1); +$record['num'] = 331; + +$conn->AutoExecute('ADOXYZ',$record,'UPDATE', "lastname like 'Sm%'"); +$rs = $conn->Execute("select * from ADOXYZ where lastname like 'Sm%'"); +//adodb_pr($rs); +rs2html($rs); +} + + +testsql(); diff --git a/vendor/adodb/adodb-php/tests/test5.php b/vendor/adodb/adodb-php/tests/test5.php new file mode 100644 index 0000000..1f0daa1 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test5.php @@ -0,0 +1,48 @@ +debug=1; + $conn->PConnect("localhost","root","","xphplens"); + print $conn->databaseType.':'.$conn->GenID().'+ |
"; +while( !$rs->EOF ) { + $output[] = $rs->fields; + var_dump($rs->fields); + $rs->MoveNext(); + print ""; +} +die(); + + +$p = $conn->Prepare('insert into products (productname,unitprice,dcreated) values (?,?,?)'); +echo "
"; +print_r($p); + +$conn->debug=1; +$conn->Execute($p,array('John'.rand(),33.3,$conn->DBDate(time()))); + +$p = $conn->Prepare('select * from products where productname like ?'); +$arr = $conn->getarray($p,array('V%')); +print_r($arr); +die(); + +//$conn = ADONewConnection("mssql"); +//$conn->Connect('mangrove','sa','natsoft','ai'); + +//$conn->Connect('mangrove','sa','natsoft','ai'); +$conn->debug=1; +$conn->Execute('delete from blobtest'); + +$conn->Execute('insert into blobtest (id) values(1)'); +$conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1'); +$rs = $conn->Execute('select b1 from blobtest where id=1'); + +$output = "c:\\temp\\test_out-".date('H-i-s').".gif"; +print "Saving file $output, size=".strlen($rs->fields[0]).""; +$fd = fopen($output, "wb"); +fwrite($fd, $rs->fields[0]); +fclose($fd); + +print " View Image"; +//$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest'); +//rs2html($rs); diff --git a/vendor/adodb/adodb-php/tests/testoci8.php b/vendor/adodb/adodb-php/tests/testoci8.php new file mode 100644 index 0000000..af748e9 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testoci8.php @@ -0,0 +1,84 @@ + +
+PConnect('','scott','natsoft'); + if (!empty($testblob)) { + $varHoldingBlob = 'ABC DEF GEF John TEST'; + $num = time()%10240; + // create table atable (id integer, ablob blob); + $db->Execute('insert into ATABLE (id,ablob) values('.$num.',empty_blob())'); + $db->UpdateBlob('ATABLE', 'ablob', $varHoldingBlob, 'id='.$num, 'BLOB'); + + $rs = $db->Execute('select * from atable'); + + if (!$rs) die("Empty RS"); + if ($rs->EOF) die("EOF RS"); + rs2html($rs); + } + $stmt = $db->Prepare('select * from adoxyz where id=?'); + for ($i = 1; $i <= 10; $i++) { + $rs = $db->Execute( + $stmt, + array($i)); + + if (!$rs) die("Empty RS"); + if ($rs->EOF) die("EOF RS"); + rs2html($rs); + } +} +if (1) { + $db = ADONewConnection('oci8'); + $db->PConnect('','scott','natsoft'); + $db->debug = true; + $db->Execute("delete from emp where ename='John'"); + print $db->Affected_Rows().'
'; + $stmt = $db->Prepare('insert into emp (empno, ename) values (:empno, :ename)'); + $rs = $db->Execute($stmt,array('empno'=>4321,'ename'=>'John')); + // prepare not quite ready for prime time + //$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John')); + if (!$rs) die("Empty RS"); + + $db->setfetchmode(ADODB_FETCH_NUM); + + $vv = 'A%'; + $stmt = $db->PrepareSP("BEGIN adodb.open_tab2(:rs,:tt); END;",true); + $db->OutParameter($stmt, $cur, 'rs', -1, OCI_B_CURSOR); + $db->OutParameter($stmt, $vv, 'tt'); + $rs = $db->Execute($stmt); + while (!$rs->EOF) { + adodb_pr($rs->fields); + $rs->MoveNext(); + } + echo " val = $vv"; + +} + +if (0) { + $db = ADONewConnection('odbc_oracle'); + if (!$db->PConnect('local_oracle','scott','tiger')) die('fail connect'); + $db->debug = true; + $rs = $db->Execute( + 'select * from adoxyz where firstname=? and trim(lastname)=?', + array('first'=>'Caroline','last'=>'Miranda')); + if (!$rs) die("Empty RS"); + if ($rs->EOF) die("EOF RS"); + rs2html($rs); +} diff --git a/vendor/adodb/adodb-php/tests/testoci8cursor.php b/vendor/adodb/adodb-php/tests/testoci8cursor.php new file mode 100644 index 0000000..1ea59c0 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testoci8cursor.php @@ -0,0 +1,110 @@ +PConnect('','scott','natsoft'); + $db->debug = 99; + + +/* +*/ + + define('MYNUM',5); + + + $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS,'A%'); END;"); + + if ($rs && !$rs->EOF) { + print "Test 1 RowCount: ".$rs->RecordCount().""; + } else { + print "Error in using Cursor Variables 1
"; + } + + print "
Testing Stored Procedures for oci8
"; + + $stid = $db->PrepareSP('BEGIN adodb.myproc('.MYNUM.', :myov); END;'); + $db->OutParameter($stid, $myov, 'myov'); + $db->Execute($stid); + if ($myov != MYNUM) print "Error with myproc
"; + + + $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;",true); + $a1 = 'Malaysia'; + //$a2 = ''; # a2 doesn't even need to be defined! + $db->InParameter($stmt,$a1,'a1'); + $db->OutParameter($stmt,$a2,'a2'); + $rs = $db->Execute($stmt); + if ($rs) { + if ($a2 !== 'Cinta Hati Malaysia') print "Stored Procedure Error: a2 = $a2"; + else echo "OK: a2=$a2
"; + } else { + print "Error in using Stored Procedure IN/Out Variables
"; + } + + + $tname = 'A%'; + + $stmt = $db->PrepareSP('select * from tab where tname like :tablename'); + $db->Parameter($stmt,$tname,'tablename'); + $rs = $db->Execute($stmt); + rs2html($rs); diff --git a/vendor/adodb/adodb-php/tests/testpaging.php b/vendor/adodb/adodb-php/tests/testpaging.php new file mode 100644 index 0000000..fe579d5 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testpaging.php @@ -0,0 +1,87 @@ +PConnect('localhost','tester','test','test'); +} + +if ($driver == 'access') { + $db = NewADOConnection('access'); + $db->PConnect("nwind", "", "", ""); +} + +if ($driver == 'ibase') { + $db = NewADOConnection('ibase'); + $db->PConnect("localhost:e:\\firebird\\examples\\employee.gdb", "sysdba", "masterkey", ""); + $sql = 'select distinct firstname, lastname from adoxyz order by firstname'; + +} +if ($driver == 'mssql') { + $db = NewADOConnection('mssql'); + $db->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind'); +} +if ($driver == 'oci8') { + $db = NewADOConnection('oci8'); + $db->Connect('','scott','natsoft'); + +$sql = "select * from (select ID, firstname as \"First Name\", lastname as \"Last Name\" from adoxyz + order by 1)"; +} + +if ($driver == 'access') { + $db = NewADOConnection('access'); + $db->Connect('nwind'); +} + +if (empty($driver) or $driver == 'mysql') { + $db = NewADOConnection('mysql'); + $db->Connect('localhost','root','','test'); +} + +//$db->pageExecuteCountRows = false; + +$db->debug = true; + +if (0) { +$rs = $db->Execute($sql); +include_once('../toexport.inc.php'); +print "
"; +print rs2csv($rs); # return a string + +print '"; +} + +$pager = new ADODB_Pager($db,$sql); +$pager->showPageLinks = true; +$pager->linksPerPage = 10; +$pager->cache = 60; +$pager->Render($rows=7); diff --git a/vendor/adodb/adodb-php/tests/testpear.php b/vendor/adodb/adodb-php/tests/testpear.php new file mode 100644 index 0000000..3f209c1 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testpear.php @@ -0,0 +1,35 @@ +setFetchMode(ADODB_FETCH_ASSOC); +$rs = $db->Query('select firstname,lastname from adoxyz'); +$cnt = 0; +while ($arr = $rs->FetchRow()) { + print_r($arr); + print "
'; +$rs->MoveFirst(); # note, some databases do not support MoveFirst +print rs2tab($rs); # return a string + +print '
'; +$rs->MoveFirst(); +rs2tabout($rs); # send to stdout directly +print "
"; + $cnt += 1; +} + +if ($cnt != 50) print "Error in \$cnt = $cnt"; diff --git a/vendor/adodb/adodb-php/tests/testsessions.php b/vendor/adodb/adodb-php/tests/testsessions.php new file mode 100644 index 0000000..2ca7342 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testsessions.php @@ -0,0 +1,100 @@ +Notify Expiring=$ref, sessionkey=$key"; +} + +//------------------------------------------------------------------- + +error_reporting(E_ALL); + + +ob_start(); +include('../session/adodb-cryptsession2.php'); + + +$options['debug'] = 1; +$db = 'postgres'; + +#### CONNECTION +switch($db) { +case 'oci8': + $options['table'] = 'adodb_sessions2'; + ADOdb_Session::config('oci8', 'mobydick', 'jdev', 'natsoft', 'mobydick',$options); + break; + +case 'postgres': + $options['table'] = 'sessions2'; + ADOdb_Session::config('postgres', 'localhost', 'postgres', 'natsoft', 'northwind',$options); + break; + +case 'mysql': +default: + $options['table'] = 'sessions2'; + ADOdb_Session::config('mysql', 'localhost', 'root', '', 'xphplens_2',$options); + break; + + +} + + + +#### SETUP NOTIFICATION + $USER = 'JLIM'.rand(); + $ADODB_SESSION_EXPIRE_NOTIFY = array('USER','NotifyExpire'); + + adodb_session_create_table(); + session_start(); + + adodb_session_regenerate_id(); + +### SETUP SESSION VARIABLES + if (empty($_SESSION['MONKEY'])) $_SESSION['MONKEY'] = array(1,'abc',44.41); + else $_SESSION['MONKEY'][0] += 1; + if (!isset($_GET['nochange'])) @$_SESSION['AVAR'] += 1; + + +### START DISPLAY + print "PHP ".PHP_VERSION."
"; + print "\$_SESSION['AVAR']={$_SESSION['AVAR']}
"; + + print "
Cookies: "; + print_r($_COOKIE); + + var_dump($_SESSION['MONKEY']); + +### RANDOMLY PERFORM Garbage Collection +### In real-production environment, this is done for you +### by php's session extension, which calls adodb_sess_gc() +### automatically for you. See php.ini's +### session.cookie_lifetime and session.gc_probability + + if (rand() % 5 == 0) { + + print "Garbage Collection
"; + adodb_sess_gc(10); + + if (rand() % 2 == 0) { + print "Random own session destroy
"; + session_destroy(); + } + } else { + $DB = ADODB_Session::_conn(); + $sessk = $DB->qstr('%AZ'.rand().time()); + $olddate = $DB->DBTimeStamp(time()-30*24*3600); + $rr = $DB->qstr(rand()); + $DB->Execute("insert into {$options['table']} (sesskey,expiry,expireref,sessdata,created,modified) values ($sessk,$olddate, $rr,'',$olddate,$olddate)"); + } diff --git a/vendor/adodb/adodb-php/tests/time.php b/vendor/adodb/adodb-php/tests/time.php new file mode 100644 index 0000000..8261e1e --- /dev/null +++ b/vendor/adodb/adodb-php/tests/time.php @@ -0,0 +1,16 @@ + +" ); +echo( "Converted: $convertedDate" ); //why is string returned as one day (3 not 4) less for this example?? diff --git a/vendor/adodb/adodb-php/tests/tmssql.php b/vendor/adodb/adodb-php/tests/tmssql.php new file mode 100644 index 0000000..0f81311 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/tmssql.php @@ -0,0 +1,79 @@ +mssql"; + $db = mssql_connect('JAGUAR\vsdotnet','adodb','natsoft') or die('No Connection'); + mssql_select_db('northwind',$db); + + $rs = mssql_query('select getdate() as date',$db); + $o = mssql_fetch_row($rs); + print_r($o); + mssql_free_result($rs); + + print "Delete
"; flush(); + $rs2 = mssql_query('delete from adoxyz',$db); + $p = mssql_num_rows($rs2); + mssql_free_result($rs2); + +} + +function tpear() +{ +include_once('DB.php'); + + print "PEAR
"; + $username = 'adodb'; + $password = 'natsoft'; + $hostname = 'JAGUAR\vsdotnet'; + $databasename = 'northwind'; + + $dsn = "mssql://$username:$password@$hostname/$databasename"; + $conn = DB::connect($dsn); + print "date=".$conn->GetOne('select getdate()')."
"; + @$conn->query('create table tester (id integer)'); + print "Delete
"; flush(); + $rs = $conn->query('delete from tester'); + print "date=".$conn->GetOne('select getdate()')."
"; +} + +function tadodb() +{ +include_once('../adodb.inc.php'); + + print "ADOdb
"; + $conn = NewADOConnection('mssql'); + $conn->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind'); +// $conn->debug=1; + print "date=".$conn->GetOne('select getdate()')."
"; + $conn->Execute('create table tester (id integer)'); + print "Delete
"; flush(); + $rs = $conn->Execute('delete from tester'); + print "date=".$conn->GetOne('select getdate()')."
"; +} + + +$ACCEPTIP = '127.0.0.1'; + +$remote = $_SERVER["REMOTE_ADDR"]; + +if (!empty($ACCEPTIP)) + if ($remote != '127.0.0.1' && $remote != $ACCEPTIP) + die("Unauthorised client: '$remote'"); + +?> +mssql +pear +adodb + ++ \ No newline at end of file diff --git a/vendor/adodb/adodb-php/tests/xmlschema.xml b/vendor/adodb/adodb-php/tests/xmlschema.xml new file mode 100644 index 0000000..ea48ae2 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/xmlschema.xml @@ -0,0 +1,33 @@ + ++
++ ++ + + ++ + + ++ id + + + + +id + + +SQL to be executed only on specific platforms ++ insert into mytable ( row1, row2 ) values ( 12, 'postgres stuff' ) + ++ insert into mytable ( row1, row2 ) values ( 12, 'mysql stuff' ) + ++ INSERT into simple_table ( name, description ) values ( '12', 'Microsoft stuff' ) + ++ \ No newline at end of file -- cgit v1.2.3-54-g00ecf+
++ +An integer row that's a primary key and autoincrements ++ + + +A 16 character varchar row that can't be null ++ + +row1 + row2 + + +SQL to be executed only on specific platforms ++ insert into mytable ( row1, row2 ) values ( 12, 'postgres stuff' ) + ++ insert into mytable ( row1, row2 ) values ( 12, 'mysql stuff' ) + ++ insert into mytable ( row1, row2 ) values ( 12, 'Microsoft stuff' ) + ++
++