From 536ff0988d1affc1134b47581a49ee15a58a2984 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sun, 4 Mar 2018 19:06:46 +0900 Subject: [PATCH] =?UTF-8?q?adodb=EB=A5=BC=20composer=EB=A1=9C=20=EB=B6=88?= =?UTF-8?q?=EB=9F=AC=EC=98=A4=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 +- composer.lock | 56 +- f_func/class._DB.php | 1 - vendor/adodb/adodb-php/.gitattributes | 17 + vendor/adodb/adodb-php/.gitignore | 10 + .../adodb/adodb-php}/.mailmap | 0 .../adodb/adodb-php}/LICENSE.md | 0 .../adodb/adodb-php}/README.md | 0 .../adodb-php}/adodb-active-record.inc.php | 0 .../adodb-php}/adodb-active-recordx.inc.php | 0 .../adodb/adodb-php}/adodb-csvlib.inc.php | 0 .../adodb/adodb-php}/adodb-datadict.inc.php | 0 .../adodb/adodb-php}/adodb-error.inc.php | 0 .../adodb-php}/adodb-errorhandler.inc.php | 0 .../adodb/adodb-php}/adodb-errorpear.inc.php | 0 .../adodb/adodb-php}/adodb-exceptions.inc.php | 0 .../adodb/adodb-php}/adodb-iterator.inc.php | 0 .../adodb/adodb-php}/adodb-lib.inc.php | 0 .../adodb-php}/adodb-memcache.lib.inc.php | 0 .../adodb/adodb-php}/adodb-pager.inc.php | 0 .../adodb/adodb-php}/adodb-pear.inc.php | 0 .../adodb/adodb-php}/adodb-perf.inc.php | 0 .../adodb/adodb-php}/adodb-php4.inc.php | 0 .../adodb/adodb-php}/adodb-time.inc.php | 0 .../adodb/adodb-php}/adodb-xmlschema.inc.php | 0 .../adodb-php}/adodb-xmlschema03.inc.php | 0 .../adodb/adodb-php}/adodb.inc.php | 0 .../adodb/adodb-php}/composer.json | 0 .../adodb/adodb-php}/contrib/toxmlrpc.inc.php | 0 .../adodb-php}/cute_icons_for_site/adodb.gif | Bin .../adodb-php}/cute_icons_for_site/adodb2.gif | Bin .../datadict/datadict-access.inc.php | 0 .../adodb-php}/datadict/datadict-db2.inc.php | 0 .../datadict/datadict-firebird.inc.php | 0 .../datadict/datadict-generic.inc.php | 0 .../datadict/datadict-ibase.inc.php | 0 .../datadict/datadict-informix.inc.php | 0 .../datadict/datadict-mssql.inc.php | 0 .../datadict/datadict-mssqlnative.inc.php | 0 .../datadict/datadict-mysql.inc.php | 0 .../adodb-php}/datadict/datadict-oci8.inc.php | 0 .../datadict/datadict-postgres.inc.php | 0 .../datadict/datadict-sapdb.inc.php | 0 .../datadict/datadict-sqlite.inc.php | 0 .../datadict/datadict-sybase.inc.php | 0 .../adodb/adodb-php}/docs/README.md | 0 .../adodb/adodb-php}/docs/adodb.gif | Bin .../adodb/adodb-php}/docs/adodb2.gif | Bin .../adodb/adodb-php}/docs/changelog.md | 0 .../adodb/adodb-php}/docs/changelog_v2.x.md | 0 .../adodb/adodb-php}/docs/changelog_v3.x.md | 0 .../adodb/adodb-php}/docs/changelog_v4+5.md | 0 .../adodb/adodb-php}/docs/changelog_v4.x.md | 0 .../adodb-php}/drivers/adodb-access.inc.php | 0 .../adodb-php}/drivers/adodb-ado.inc.php | 0 .../adodb-php}/drivers/adodb-ado5.inc.php | 0 .../drivers/adodb-ado_access.inc.php | 0 .../drivers/adodb-ado_mssql.inc.php | 0 .../adodb-php}/drivers/adodb-ads.inc.php | 0 .../drivers/adodb-borland_ibase.inc.php | 0 .../adodb-php}/drivers/adodb-csv.inc.php | 0 .../adodb-php}/drivers/adodb-db2.inc.php | 0 .../adodb-php}/drivers/adodb-db2oci.inc.php | 0 .../adodb-php}/drivers/adodb-db2ora.inc.php | 0 .../adodb-php}/drivers/adodb-fbsql.inc.php | 0 .../adodb-php}/drivers/adodb-firebird.inc.php | 0 .../adodb-php}/drivers/adodb-ibase.inc.php | 0 .../adodb-php}/drivers/adodb-informix.inc.php | 0 .../drivers/adodb-informix72.inc.php | 0 .../adodb-php}/drivers/adodb-ldap.inc.php | 0 .../adodb-php}/drivers/adodb-mssql.inc.php | 0 .../adodb-php}/drivers/adodb-mssql_n.inc.php | 0 .../drivers/adodb-mssqlnative.inc.php | 0 .../adodb-php}/drivers/adodb-mssqlpo.inc.php | 0 .../adodb-php}/drivers/adodb-mysql.inc.php | 0 .../adodb-php}/drivers/adodb-mysqli.inc.php | 0 .../adodb-php}/drivers/adodb-mysqlpo.inc.php | 0 .../adodb-php}/drivers/adodb-mysqlt.inc.php | 0 .../adodb-php}/drivers/adodb-netezza.inc.php | 0 .../adodb-php}/drivers/adodb-oci8.inc.php | 0 .../adodb-php}/drivers/adodb-oci805.inc.php | 0 .../adodb-php}/drivers/adodb-oci8po.inc.php | 0 .../drivers/adodb-oci8quercus.inc.php | 0 .../adodb-php}/drivers/adodb-odbc.inc.php | 0 .../adodb-php}/drivers/adodb-odbc_db2.inc.php | 0 .../drivers/adodb-odbc_mssql.inc.php | 0 .../drivers/adodb-odbc_oracle.inc.php | 0 .../adodb-php}/drivers/adodb-odbtp.inc.php | 0 .../drivers/adodb-odbtp_unicode.inc.php | 0 .../adodb-php}/drivers/adodb-oracle.inc.php | 0 .../adodb-php}/drivers/adodb-pdo.inc.php | 0 .../drivers/adodb-pdo_mssql.inc.php | 0 .../drivers/adodb-pdo_mysql.inc.php | 0 .../adodb-php}/drivers/adodb-pdo_oci.inc.php | 0 .../drivers/adodb-pdo_pgsql.inc.php | 0 .../drivers/adodb-pdo_sqlite.inc.php | 0 .../drivers/adodb-pdo_sqlsrv.inc.php | 0 .../adodb-php}/drivers/adodb-postgres.inc.php | 0 .../drivers/adodb-postgres64.inc.php | 0 .../drivers/adodb-postgres7.inc.php | 0 .../drivers/adodb-postgres8.inc.php | 0 .../drivers/adodb-postgres9.inc.php | 0 .../adodb-php}/drivers/adodb-proxy.inc.php | 0 .../adodb-php}/drivers/adodb-sapdb.inc.php | 0 .../drivers/adodb-sqlanywhere.inc.php | 0 .../adodb-php}/drivers/adodb-sqlite.inc.php | 0 .../adodb-php}/drivers/adodb-sqlite3.inc.php | 0 .../adodb-php}/drivers/adodb-sqlitepo.inc.php | 0 .../adodb-php}/drivers/adodb-sybase.inc.php | 0 .../drivers/adodb-sybase_ase.inc.php | 0 .../adodb-php/drivers/adodb-text.inc.php | 389 ++++ .../adodb-php}/drivers/adodb-vfp.inc.php | 0 .../adodb/adodb-php}/lang/adodb-ar.inc.php | 0 .../adodb/adodb-php}/lang/adodb-bg.inc.php | 0 .../adodb/adodb-php}/lang/adodb-ca.inc.php | 0 .../adodb/adodb-php}/lang/adodb-cn.inc.php | 0 .../adodb/adodb-php}/lang/adodb-cz.inc.php | 0 .../adodb/adodb-php}/lang/adodb-da.inc.php | 0 .../adodb/adodb-php}/lang/adodb-de.inc.php | 0 .../adodb/adodb-php}/lang/adodb-en.inc.php | 0 .../adodb/adodb-php}/lang/adodb-eo.inc.php | 0 .../adodb/adodb-php}/lang/adodb-es.inc.php | 0 .../adodb/adodb-php}/lang/adodb-fa.inc.php | 0 .../adodb/adodb-php}/lang/adodb-fr.inc.php | 0 .../adodb/adodb-php}/lang/adodb-hu.inc.php | 0 .../adodb/adodb-php}/lang/adodb-it.inc.php | 0 .../adodb/adodb-php}/lang/adodb-nl.inc.php | 0 .../adodb/adodb-php}/lang/adodb-pl.inc.php | 0 .../adodb/adodb-php}/lang/adodb-pt-br.inc.php | 0 .../adodb/adodb-php}/lang/adodb-ro.inc.php | 0 .../adodb/adodb-php}/lang/adodb-ru.inc.php | 0 .../adodb/adodb-php}/lang/adodb-sv.inc.php | 0 .../adodb/adodb-php}/lang/adodb-th.inc.php | 0 .../adodb/adodb-php}/lang/adodb-uk.inc.php | 0 .../adodb-php}/pear/Auth/Container/ADOdb.php | 0 .../adodb-php}/pear/auth_adodb_example.php | 0 .../adodb/adodb-php}/pear/readme.Auth.txt | 0 .../adodb/adodb-php}/perf/perf-db2.inc.php | 0 .../adodb-php}/perf/perf-informix.inc.php | 0 .../adodb/adodb-php}/perf/perf-mssql.inc.php | 0 .../adodb-php}/perf/perf-mssqlnative.inc.php | 0 .../adodb/adodb-php}/perf/perf-mysql.inc.php | 0 .../adodb/adodb-php}/perf/perf-oci8.inc.php | 0 .../adodb-php}/perf/perf-postgres.inc.php | 0 .../adodb/adodb-php}/pivottable.inc.php | 0 .../replicate/adodb-replicate.inc.php | 1181 +++++++++++ .../adodb-php/replicate/replicate-steps.php | 137 ++ vendor/adodb/adodb-php/replicate/test-tnb.php | 421 ++++ .../adodb/adodb-php}/rsfilter.inc.php | 0 vendor/adodb/adodb-php/scripts/.gitignore | 2 + vendor/adodb/adodb-php/scripts/TARADO5.BAT | 49 + .../adodb/adodb-php/scripts/buildrelease.py | 270 +++ .../adodb/adodb-php/scripts/updateversion.py | 399 ++++ .../adodb/adodb-php/scripts/uploadrelease.py | 172 ++ .../adodb/adodb-php}/server.php | 0 .../session/adodb-compress-bzip2.php | 0 .../session/adodb-compress-gzip.php | 0 .../adodb-php}/session/adodb-cryptsession.php | 0 .../session/adodb-cryptsession2.php | 0 .../session/adodb-encrypt-mcrypt.php | 0 .../adodb-php}/session/adodb-encrypt-md5.php | 0 .../session/adodb-encrypt-secret.php | 0 .../adodb-php}/session/adodb-encrypt-sha1.php | 0 .../adodb/adodb-php}/session/adodb-sess.txt | 0 .../adodb-php}/session/adodb-session-clob.php | 0 .../session/adodb-session-clob2.php | 0 .../adodb-php}/session/adodb-session.php | 0 .../adodb-php}/session/adodb-session2.php | 0 .../session/adodb-sessions.mysql.sql | 0 .../session/adodb-sessions.oracle.clob.sql | 0 .../session/adodb-sessions.oracle.sql | 0 .../adodb/adodb-php}/session/crypt.inc.php | 0 .../session/old/adodb-cryptsession.php | 0 .../session/old/adodb-session-clob.php | 0 .../adodb-php}/session/old/adodb-session.php | 0 .../adodb-php}/session/old/crypt.inc.php | 0 .../adodb-php}/session/session_schema.xml | 0 .../adodb-php}/session/session_schema2.xml | 0 vendor/adodb/adodb-php/tests/benchmark.php | 86 + vendor/adodb/adodb-php/tests/client.php | 199 ++ vendor/adodb/adodb-php/tests/pdo.php | 92 + .../adodb-php/tests/test-active-record.php | 140 ++ .../adodb-php/tests/test-active-recs2.php | 76 + .../adodb-php/tests/test-active-relations.php | 85 + .../tests/test-active-relationsx.php | 418 ++++ .../adodb/adodb-php/tests/test-datadict.php | 251 +++ vendor/adodb/adodb-php/tests/test-perf.php | 48 + vendor/adodb/adodb-php/tests/test-pgblob.php | 86 + vendor/adodb/adodb-php/tests/test-php5.php | 116 ++ .../adodb/adodb-php/tests/test-xmlschema.php | 53 + vendor/adodb/adodb-php/tests/test.php | 1781 +++++++++++++++++ vendor/adodb/adodb-php/tests/test2.php | 25 + vendor/adodb/adodb-php/tests/test3.php | 44 + vendor/adodb/adodb-php/tests/test4.php | 144 ++ vendor/adodb/adodb-php/tests/test5.php | 48 + .../adodb/adodb-php/tests/test_rs_array.php | 46 + vendor/adodb/adodb-php/tests/testcache.php | 30 + .../adodb-php/tests/testdatabases.inc.php | 478 +++++ vendor/adodb/adodb-php/tests/testgenid.php | 35 + vendor/adodb/adodb-php/tests/testmssql.php | 77 + vendor/adodb/adodb-php/tests/testoci8.php | 84 + .../adodb/adodb-php/tests/testoci8cursor.php | 110 + vendor/adodb/adodb-php/tests/testpaging.php | 87 + vendor/adodb/adodb-php/tests/testpear.php | 35 + vendor/adodb/adodb-php/tests/testsessions.php | 100 + vendor/adodb/adodb-php/tests/time.php | 16 + vendor/adodb/adodb-php/tests/tmssql.php | 79 + .../adodb/adodb-php/tests/xmlschema-mssql.xml | 34 + vendor/adodb/adodb-php/tests/xmlschema.xml | 33 + .../adodb/adodb-php}/toexport.inc.php | 0 .../adodb/adodb-php}/tohtml.inc.php | 0 .../adodb/adodb-php}/xmlschema.dtd | 0 .../adodb/adodb-php}/xmlschema03.dtd | 0 .../adodb/adodb-php}/xsl/convert-0.1-0.2.xsl | 0 .../adodb/adodb-php}/xsl/convert-0.1-0.3.xsl | 0 .../adodb/adodb-php}/xsl/convert-0.2-0.1.xsl | 0 .../adodb/adodb-php}/xsl/convert-0.2-0.3.xsl | 0 .../adodb/adodb-php}/xsl/remove-0.2.xsl | 0 .../adodb/adodb-php}/xsl/remove-0.3.xsl | 0 vendor/composer/autoload_files.php | 1 + vendor/composer/autoload_static.php | 1 + vendor/composer/installed.json | 56 + 222 files changed, 8098 insertions(+), 3 deletions(-) create mode 100644 vendor/adodb/adodb-php/.gitattributes create mode 100644 vendor/adodb/adodb-php/.gitignore rename {e_lib/adodb5 => vendor/adodb/adodb-php}/.mailmap (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/LICENSE.md (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/README.md (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-active-record.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-active-recordx.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-csvlib.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-datadict.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-error.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-errorhandler.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-errorpear.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-exceptions.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-iterator.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-lib.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-memcache.lib.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-pager.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-pear.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-perf.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-php4.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-time.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-xmlschema.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb-xmlschema03.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/adodb.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/composer.json (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/contrib/toxmlrpc.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/cute_icons_for_site/adodb.gif (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/cute_icons_for_site/adodb2.gif (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-access.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-db2.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-firebird.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-generic.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-ibase.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-informix.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-mssql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-mssqlnative.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-mysql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-oci8.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-postgres.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-sapdb.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-sqlite.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/datadict/datadict-sybase.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/docs/README.md (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/docs/adodb.gif (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/docs/adodb2.gif (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/docs/changelog.md (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/docs/changelog_v2.x.md (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/docs/changelog_v3.x.md (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/docs/changelog_v4+5.md (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/docs/changelog_v4.x.md (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-access.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-ado.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-ado5.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-ado_access.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-ado_mssql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-ads.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-borland_ibase.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-csv.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-db2.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-db2oci.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-db2ora.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-fbsql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-firebird.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-ibase.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-informix.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-informix72.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-ldap.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-mssql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-mssql_n.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-mssqlnative.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-mssqlpo.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-mysql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-mysqli.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-mysqlpo.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-mysqlt.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-netezza.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-oci8.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-oci805.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-oci8po.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-oci8quercus.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-odbc.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-odbc_db2.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-odbc_mssql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-odbc_oracle.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-odbtp.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-odbtp_unicode.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-oracle.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-pdo.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-pdo_mssql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-pdo_mysql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-pdo_oci.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-pdo_pgsql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-pdo_sqlite.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-pdo_sqlsrv.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-postgres.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-postgres64.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-postgres7.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-postgres8.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-postgres9.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-proxy.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-sapdb.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-sqlanywhere.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-sqlite.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-sqlite3.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-sqlitepo.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-sybase.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-sybase_ase.inc.php (100%) create mode 100644 vendor/adodb/adodb-php/drivers/adodb-text.inc.php rename {e_lib/adodb5 => vendor/adodb/adodb-php}/drivers/adodb-vfp.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-ar.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-bg.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-ca.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-cn.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-cz.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-da.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-de.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-en.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-eo.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-es.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-fa.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-fr.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-hu.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-it.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-nl.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-pl.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-pt-br.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-ro.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-ru.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-sv.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-th.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/lang/adodb-uk.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/pear/Auth/Container/ADOdb.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/pear/auth_adodb_example.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/pear/readme.Auth.txt (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/perf/perf-db2.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/perf/perf-informix.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/perf/perf-mssql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/perf/perf-mssqlnative.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/perf/perf-mysql.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/perf/perf-oci8.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/perf/perf-postgres.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/pivottable.inc.php (100%) create mode 100644 vendor/adodb/adodb-php/replicate/adodb-replicate.inc.php create mode 100644 vendor/adodb/adodb-php/replicate/replicate-steps.php create mode 100644 vendor/adodb/adodb-php/replicate/test-tnb.php rename {e_lib/adodb5 => vendor/adodb/adodb-php}/rsfilter.inc.php (100%) create mode 100644 vendor/adodb/adodb-php/scripts/.gitignore create mode 100644 vendor/adodb/adodb-php/scripts/TARADO5.BAT create mode 100644 vendor/adodb/adodb-php/scripts/buildrelease.py create mode 100644 vendor/adodb/adodb-php/scripts/updateversion.py create mode 100644 vendor/adodb/adodb-php/scripts/uploadrelease.py rename {e_lib/adodb5 => vendor/adodb/adodb-php}/server.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-compress-bzip2.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-compress-gzip.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-cryptsession.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-cryptsession2.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-encrypt-mcrypt.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-encrypt-md5.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-encrypt-secret.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-encrypt-sha1.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-sess.txt (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-session-clob.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-session-clob2.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-session.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-session2.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-sessions.mysql.sql (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-sessions.oracle.clob.sql (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/adodb-sessions.oracle.sql (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/crypt.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/old/adodb-cryptsession.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/old/adodb-session-clob.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/old/adodb-session.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/old/crypt.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/session_schema.xml (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/session/session_schema2.xml (100%) create mode 100644 vendor/adodb/adodb-php/tests/benchmark.php create mode 100644 vendor/adodb/adodb-php/tests/client.php create mode 100644 vendor/adodb/adodb-php/tests/pdo.php create mode 100644 vendor/adodb/adodb-php/tests/test-active-record.php create mode 100644 vendor/adodb/adodb-php/tests/test-active-recs2.php create mode 100644 vendor/adodb/adodb-php/tests/test-active-relations.php create mode 100644 vendor/adodb/adodb-php/tests/test-active-relationsx.php create mode 100644 vendor/adodb/adodb-php/tests/test-datadict.php create mode 100644 vendor/adodb/adodb-php/tests/test-perf.php create mode 100644 vendor/adodb/adodb-php/tests/test-pgblob.php create mode 100644 vendor/adodb/adodb-php/tests/test-php5.php create mode 100644 vendor/adodb/adodb-php/tests/test-xmlschema.php create mode 100644 vendor/adodb/adodb-php/tests/test.php create mode 100644 vendor/adodb/adodb-php/tests/test2.php create mode 100644 vendor/adodb/adodb-php/tests/test3.php create mode 100644 vendor/adodb/adodb-php/tests/test4.php create mode 100644 vendor/adodb/adodb-php/tests/test5.php create mode 100644 vendor/adodb/adodb-php/tests/test_rs_array.php create mode 100644 vendor/adodb/adodb-php/tests/testcache.php create mode 100644 vendor/adodb/adodb-php/tests/testdatabases.inc.php create mode 100644 vendor/adodb/adodb-php/tests/testgenid.php create mode 100644 vendor/adodb/adodb-php/tests/testmssql.php create mode 100644 vendor/adodb/adodb-php/tests/testoci8.php create mode 100644 vendor/adodb/adodb-php/tests/testoci8cursor.php create mode 100644 vendor/adodb/adodb-php/tests/testpaging.php create mode 100644 vendor/adodb/adodb-php/tests/testpear.php create mode 100644 vendor/adodb/adodb-php/tests/testsessions.php create mode 100644 vendor/adodb/adodb-php/tests/time.php create mode 100644 vendor/adodb/adodb-php/tests/tmssql.php create mode 100644 vendor/adodb/adodb-php/tests/xmlschema-mssql.xml create mode 100644 vendor/adodb/adodb-php/tests/xmlschema.xml rename {e_lib/adodb5 => vendor/adodb/adodb-php}/toexport.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/tohtml.inc.php (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/xmlschema.dtd (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/xmlschema03.dtd (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/xsl/convert-0.1-0.2.xsl (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/xsl/convert-0.1-0.3.xsl (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/xsl/convert-0.2-0.1.xsl (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/xsl/convert-0.2-0.3.xsl (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/xsl/remove-0.2.xsl (100%) rename {e_lib/adodb5 => vendor/adodb/adodb-php}/xsl/remove-0.3.xsl (100%) diff --git a/composer.json b/composer.json index 75d0ffe8..f7af4de2 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,7 @@ "league/plates": "^3.3", "phpmailer/phpmailer": "^6.0", "guzzlehttp/guzzle": "^6.3", - "leafo/scssphp": "^0.7.5" + "leafo/scssphp": "^0.7.5", + "adodb/adodb-php": "^5.20" } } diff --git a/composer.lock b/composer.lock index f9dacdfd..78605f91 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,62 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "7b9fdde15b3d81d1431847e29f201587", + "content-hash": "a8d79581e2352baf2677220b715f1348", "packages": [ + { + "name": "adodb/adodb-php", + "version": "v5.20.9", + "source": { + "type": "git", + "url": "https://github.com/ADOdb/ADOdb.git", + "reference": "f601748cca1ccb86dfd427620a1692a70e681075" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ADOdb/ADOdb/zipball/f601748cca1ccb86dfd427620a1692a70e681075", + "reference": "f601748cca1ccb86dfd427620a1692a70e681075", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "autoload": { + "files": [ + "adodb.inc.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "LGPL-2.1" + ], + "authors": [ + { + "name": "John Lim", + "email": "jlim@natsoft.com", + "role": "Author" + }, + { + "name": "Damien Regad", + "role": "Current maintainer" + }, + { + "name": "Mark Newnham", + "role": "Developer" + } + ], + "description": "ADOdb is a PHP database abstraction layer library", + "homepage": "http://adodb.org/", + "keywords": [ + "abstraction", + "database", + "layer", + "library", + "php" + ], + "time": "2016-12-21T17:19:42+00:00" + }, { "name": "brandonwamboldt/utilphp", "version": "1.1.0", diff --git a/f_func/class._DB.php b/f_func/class._DB.php index 3b7bc593..5e43502f 100644 --- a/f_func/class._DB.php +++ b/f_func/class._DB.php @@ -1,6 +1,5 @@ Connect($array,[$types],[$colnames]); + + Parameter $array is the 2 dimensional array of data. The first row can contain the + column names. If column names is not defined in first row, you MUST define $colnames, + the 3rd parameter. + + Parameter $types is optional. If defined, it should contain an array matching + the number of columns in $array, with each element matching the correct type defined + by MetaType: (B,C,I,L,N). If undefined, we will probe for $this->_proberows rows + to guess the type. Only C,I and N are recognised. + + Parameter $colnames is optional. If defined, it is an array that contains the + column names of $array. If undefined, we assume the first row of $array holds the + column names. + + The Execute() function will return a recordset. The recordset works like a normal recordset. + We have partial support for SQL parsing. We process the SQL using the following rules: + + 1. SQL order by's always work for the first column ordered. Subsequent cols are ignored + + 2. All operations take place on the same table. No joins possible. In fact the FROM clause + is ignored! You can use any name for the table. + + 3. To simplify code, all columns are returned, except when selecting 1 column + + $rs = $db->Execute('select col1,col2 from table'); // sql ignored, will generate all cols + + We special case handling of 1 column because it is used in filter popups + + $rs = $db->Execute('select col1 from table'); + // sql accepted and processed -- any table name is accepted + + $rs = $db->Execute('select distinct col1 from table'); + // sql accepted and processed + +4. Where clauses are ignored, but searching with the 3rd parameter of Execute is permitted. + This has to use PHP syntax and we will eval() it. You can even use PHP functions. + + $rs = $db->Execute('select * from table',false,"\$COL1='abc' and $\COL2=3") + // the 3rd param is searched -- make sure that $COL1 is a legal column name + // and all column names must be in upper case. + +4. Group by, having, other clauses are ignored + +5. Expression columns, min(), max() are ignored + +6. All data is readonly. Only SELECTs permitted. +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +if (! defined("_ADODB_TEXT_LAYER")) { + define("_ADODB_TEXT_LAYER", 1 ); + +// for sorting in _query() +function adodb_cmp($a, $b) { + if ($a[0] == $b[0]) return 0; + return ($a[0] < $b[0]) ? -1 : 1; +} +// for sorting in _query() +function adodb_cmpr($a, $b) { + if ($a[0] == $b[0]) return 0; + return ($a[0] > $b[0]) ? -1 : 1; +} +class ADODB_text extends ADOConnection { + var $databaseType = 'text'; + + var $_origarray; // original data + var $_types; + var $_proberows = 8; + var $_colnames; + var $_skiprow1=false; + var $readOnly = true; + var $hasTransactions = false; + + var $_rezarray; + var $_reznames; + var $_reztypes; + + function __construct() + { + } + + function RSRecordCount() + { + if (!empty($this->_rezarray)) return sizeof($this->_rezarray); + + return sizeof($this->_origarray); + } + + function _insertid() + { + return false; + } + + function _affectedrows() + { + return false; + } + + // returns true or false + function PConnect(&$array, $types = false, $colnames = false) + { + return $this->Connect($array, $types, $colnames); + } + // returns true or false + function Connect(&$array, $types = false, $colnames = false) + { + if (is_string($array) and $array === 'iluvphplens') return 'me2'; + + if (!$array) { + $this->_origarray = false; + return true; + } + $row = $array[0]; + $cols = sizeof($row); + + + if ($colnames) $this->_colnames = $colnames; + else { + $this->_colnames = $array[0]; + $this->_skiprow1 = true; + } + if (!$types) { + // probe and guess the type + $types = array(); + $firstrow = true; + if ($this->_proberows > sizeof($array)) $max = sizeof($array); + else $max = $this->_proberows; + for ($j=($this->_skiprow1)?1:0;$j < $max; $j++) { + $row = $array[$j]; + if (!$row) break; + $i = -1; + foreach($row as $v) { + $i += 1; + //print " ($i ".$types[$i]. "$v) "; + $v = trim($v); + if (!preg_match('/^[+-]{0,1}[0-9\.]+$/',$v)) { + $types[$i] = 'C'; // once C, always C + continue; + } + if (isset($types[$i]) && $types[$i]=='C') continue; + if ($firstrow) { + // If empty string, we presume is character + // test for integer for 1st row only + // after that it is up to testing other rows to prove + // that it is not an integer + if (strlen($v) == 0) $types[0] = 'C'; + if (strpos($v,'.') !== false) $types[0] = 'N'; + else $types[$i] = 'I'; + continue; + } + + if (strpos($v,'.') !== false) $types[$i] = 'N'; + + } + $firstrow = false; + } + } + //print_r($types); + $this->_origarray = $array; + $this->_types = $types; + return true; + } + + + + // returns queryID or false + // We presume that the select statement is on the same table (what else?), + // with the only difference being the order by. + //You can filter by using $eval and each clause is stored in $arr .eg. $arr[1] == 'name' + // also supports SELECT [DISTINCT] COL FROM ... -- only 1 col supported + function _query($sql,$input_arr,$eval=false) + { + if ($this->_origarray === false) return false; + + $eval = $this->evalAll; + $usql = strtoupper(trim($sql)); + $usql = preg_replace("/[\t\n\r]/",' ',$usql); + $usql = preg_replace('/ *BY/i',' BY',strtoupper($usql)); + + $eregword ='([A-Z_0-9]*)'; + //print "
$sql $eval "; + if ($eval) { + $i = 0; + foreach($this->_colnames as $n) { + $n = strtoupper(trim($n)); + $eval = str_replace("\$$n","\$arr[$i]",$eval); + + $i += 1; + } + + $i = 0; + $eval = "\$rez=($eval);"; + //print "

Eval string = $eval

"; + $where_arr = array(); + + reset($this->_origarray); + while (list($k_arr,$arr) = each($this->_origarray)) { + + if ($i == 0 && $this->_skiprow1) + $where_arr[] = $arr; + else { + eval($eval); + //print " $i: result=$rez arr[0]={$arr[0]} arr[1]={$arr[1]}
\n "; + if ($rez) $where_arr[] = $arr; + } + $i += 1; + } + $this->_rezarray = $where_arr; + }else + $where_arr = $this->_origarray; + + // THIS PROJECTION CODE ONLY WORKS FOR 1 COLUMN, + // OTHERWISE IT RETURNS ALL COLUMNS + if (substr($usql,0,7) == 'SELECT ') { + $at = strpos($usql,' FROM '); + $sel = trim(substr($usql,7,$at-7)); + + $distinct = false; + if (substr($sel,0,8) == 'DISTINCT') { + $distinct = true; + $sel = trim(substr($sel,8,$at)); + } + + // $sel holds the selection clause, comma delimited + // currently we only project if one column is involved + // this is to support popups in PHPLens + if (strpos(',',$sel)===false) { + $colarr = array(); + + preg_match("/$eregword/",$sel,$colarr); + $col = $colarr[1]; + $i = 0; + $n = ''; + reset($this->_colnames); + while (list($k_n,$n) = each($this->_colnames)) { + + if ($col == strtoupper(trim($n))) break; + $i += 1; + } + + if ($n && $col) { + $distarr = array(); + $projarray = array(); + $projtypes = array($this->_types[$i]); + $projnames = array($n); + + reset($where_arr); + while (list($k_a,$a) = each($where_arr)) { + if ($i == 0 && $this->_skiprow1) { + $projarray[] = array($n); + continue; + } + + if ($distinct) { + $v = strtoupper($a[$i]); + if (! $distarr[$v]) { + $projarray[] = array($a[$i]); + $distarr[$v] = 1; + } + } else + $projarray[] = array($a[$i]); + + } //foreach + //print_r($projarray); + } + } // check 1 column in projection + } // is SELECT + + if (empty($projarray)) { + $projtypes = $this->_types; + $projarray = $where_arr; + $projnames = $this->_colnames; + } + $this->_rezarray = $projarray; + $this->_reztypes = $projtypes; + $this->_reznames = $projnames; + + + $pos = strpos($usql,' ORDER BY '); + if ($pos === false) return $this; + $orderby = trim(substr($usql,$pos+10)); + + preg_match("/$eregword/",$orderby,$arr); + if (sizeof($arr) < 2) return $this; // actually invalid sql + $col = $arr[1]; + $at = (integer) $col; + if ($at == 0) { + $i = 0; + reset($projnames); + while (list($k_n,$n) = each($projnames)) { + if (strtoupper(trim($n)) == $col) { + $at = $i+1; + break; + } + $i += 1; + } + } + + if ($at <= 0 || $at > sizeof($projarray[0])) return $this; // cannot find sort column + $at -= 1; + + // generate sort array consisting of (sortval1, row index1) (sortval2, row index2)... + $sorta = array(); + $t = $projtypes[$at]; + $num = ($t == 'I' || $t == 'N'); + for ($i=($this->_skiprow1)?1:0, $max = sizeof($projarray); $i < $max; $i++) { + $row = $projarray[$i]; + $val = ($num)?(float)$row[$at]:$row[$at]; + $sorta[]=array($val,$i); + } + + // check for desc sort + $orderby = substr($orderby,strlen($col)+1); + $arr == array(); + preg_match('/([A-Z_0-9]*)/i',$orderby,$arr); + + if (trim($arr[1]) == 'DESC') $sortf = 'adodb_cmpr'; + else $sortf = 'adodb_cmp'; + + // hasta la sorta babe + usort($sorta, $sortf); + + // rearrange original array + $arr2 = array(); + if ($this->_skiprow1) $arr2[] = $projarray[0]; + foreach($sorta as $v) { + $arr2[] = $projarray[$v[1]]; + } + + $this->_rezarray = $arr2; + return $this; + } + + /* Returns: the last error message from previous database operation */ + function ErrorMsg() + { + return ''; + } + + /* Returns: the last error number from previous database operation */ + function ErrorNo() + { + return 0; + } + + // returns true or false + function _close() + { + } + + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + + +class ADORecordSet_text extends ADORecordSet_array +{ + + var $databaseType = "text"; + + function __construct(&$conn,$mode=false) + { + parent::__construct(); + $this->InitArray($conn->_rezarray,$conn->_reztypes,$conn->_reznames); + $conn->_rezarray = false; + } + +} // class ADORecordSet_text + + +} // defined diff --git a/e_lib/adodb5/drivers/adodb-vfp.inc.php b/vendor/adodb/adodb-php/drivers/adodb-vfp.inc.php similarity index 100% rename from e_lib/adodb5/drivers/adodb-vfp.inc.php rename to vendor/adodb/adodb-php/drivers/adodb-vfp.inc.php diff --git a/e_lib/adodb5/lang/adodb-ar.inc.php b/vendor/adodb/adodb-php/lang/adodb-ar.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-ar.inc.php rename to vendor/adodb/adodb-php/lang/adodb-ar.inc.php diff --git a/e_lib/adodb5/lang/adodb-bg.inc.php b/vendor/adodb/adodb-php/lang/adodb-bg.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-bg.inc.php rename to vendor/adodb/adodb-php/lang/adodb-bg.inc.php diff --git a/e_lib/adodb5/lang/adodb-ca.inc.php b/vendor/adodb/adodb-php/lang/adodb-ca.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-ca.inc.php rename to vendor/adodb/adodb-php/lang/adodb-ca.inc.php diff --git a/e_lib/adodb5/lang/adodb-cn.inc.php b/vendor/adodb/adodb-php/lang/adodb-cn.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-cn.inc.php rename to vendor/adodb/adodb-php/lang/adodb-cn.inc.php diff --git a/e_lib/adodb5/lang/adodb-cz.inc.php b/vendor/adodb/adodb-php/lang/adodb-cz.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-cz.inc.php rename to vendor/adodb/adodb-php/lang/adodb-cz.inc.php diff --git a/e_lib/adodb5/lang/adodb-da.inc.php b/vendor/adodb/adodb-php/lang/adodb-da.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-da.inc.php rename to vendor/adodb/adodb-php/lang/adodb-da.inc.php diff --git a/e_lib/adodb5/lang/adodb-de.inc.php b/vendor/adodb/adodb-php/lang/adodb-de.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-de.inc.php rename to vendor/adodb/adodb-php/lang/adodb-de.inc.php diff --git a/e_lib/adodb5/lang/adodb-en.inc.php b/vendor/adodb/adodb-php/lang/adodb-en.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-en.inc.php rename to vendor/adodb/adodb-php/lang/adodb-en.inc.php diff --git a/e_lib/adodb5/lang/adodb-eo.inc.php b/vendor/adodb/adodb-php/lang/adodb-eo.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-eo.inc.php rename to vendor/adodb/adodb-php/lang/adodb-eo.inc.php diff --git a/e_lib/adodb5/lang/adodb-es.inc.php b/vendor/adodb/adodb-php/lang/adodb-es.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-es.inc.php rename to vendor/adodb/adodb-php/lang/adodb-es.inc.php diff --git a/e_lib/adodb5/lang/adodb-fa.inc.php b/vendor/adodb/adodb-php/lang/adodb-fa.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-fa.inc.php rename to vendor/adodb/adodb-php/lang/adodb-fa.inc.php diff --git a/e_lib/adodb5/lang/adodb-fr.inc.php b/vendor/adodb/adodb-php/lang/adodb-fr.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-fr.inc.php rename to vendor/adodb/adodb-php/lang/adodb-fr.inc.php diff --git a/e_lib/adodb5/lang/adodb-hu.inc.php b/vendor/adodb/adodb-php/lang/adodb-hu.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-hu.inc.php rename to vendor/adodb/adodb-php/lang/adodb-hu.inc.php diff --git a/e_lib/adodb5/lang/adodb-it.inc.php b/vendor/adodb/adodb-php/lang/adodb-it.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-it.inc.php rename to vendor/adodb/adodb-php/lang/adodb-it.inc.php diff --git a/e_lib/adodb5/lang/adodb-nl.inc.php b/vendor/adodb/adodb-php/lang/adodb-nl.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-nl.inc.php rename to vendor/adodb/adodb-php/lang/adodb-nl.inc.php diff --git a/e_lib/adodb5/lang/adodb-pl.inc.php b/vendor/adodb/adodb-php/lang/adodb-pl.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-pl.inc.php rename to vendor/adodb/adodb-php/lang/adodb-pl.inc.php diff --git a/e_lib/adodb5/lang/adodb-pt-br.inc.php b/vendor/adodb/adodb-php/lang/adodb-pt-br.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-pt-br.inc.php rename to vendor/adodb/adodb-php/lang/adodb-pt-br.inc.php diff --git a/e_lib/adodb5/lang/adodb-ro.inc.php b/vendor/adodb/adodb-php/lang/adodb-ro.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-ro.inc.php rename to vendor/adodb/adodb-php/lang/adodb-ro.inc.php diff --git a/e_lib/adodb5/lang/adodb-ru.inc.php b/vendor/adodb/adodb-php/lang/adodb-ru.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-ru.inc.php rename to vendor/adodb/adodb-php/lang/adodb-ru.inc.php diff --git a/e_lib/adodb5/lang/adodb-sv.inc.php b/vendor/adodb/adodb-php/lang/adodb-sv.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-sv.inc.php rename to vendor/adodb/adodb-php/lang/adodb-sv.inc.php diff --git a/e_lib/adodb5/lang/adodb-th.inc.php b/vendor/adodb/adodb-php/lang/adodb-th.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-th.inc.php rename to vendor/adodb/adodb-php/lang/adodb-th.inc.php diff --git a/e_lib/adodb5/lang/adodb-uk.inc.php b/vendor/adodb/adodb-php/lang/adodb-uk.inc.php similarity index 100% rename from e_lib/adodb5/lang/adodb-uk.inc.php rename to vendor/adodb/adodb-php/lang/adodb-uk.inc.php diff --git a/e_lib/adodb5/pear/Auth/Container/ADOdb.php b/vendor/adodb/adodb-php/pear/Auth/Container/ADOdb.php similarity index 100% rename from e_lib/adodb5/pear/Auth/Container/ADOdb.php rename to vendor/adodb/adodb-php/pear/Auth/Container/ADOdb.php diff --git a/e_lib/adodb5/pear/auth_adodb_example.php b/vendor/adodb/adodb-php/pear/auth_adodb_example.php similarity index 100% rename from e_lib/adodb5/pear/auth_adodb_example.php rename to vendor/adodb/adodb-php/pear/auth_adodb_example.php diff --git a/e_lib/adodb5/pear/readme.Auth.txt b/vendor/adodb/adodb-php/pear/readme.Auth.txt similarity index 100% rename from e_lib/adodb5/pear/readme.Auth.txt rename to vendor/adodb/adodb-php/pear/readme.Auth.txt diff --git a/e_lib/adodb5/perf/perf-db2.inc.php b/vendor/adodb/adodb-php/perf/perf-db2.inc.php similarity index 100% rename from e_lib/adodb5/perf/perf-db2.inc.php rename to vendor/adodb/adodb-php/perf/perf-db2.inc.php diff --git a/e_lib/adodb5/perf/perf-informix.inc.php b/vendor/adodb/adodb-php/perf/perf-informix.inc.php similarity index 100% rename from e_lib/adodb5/perf/perf-informix.inc.php rename to vendor/adodb/adodb-php/perf/perf-informix.inc.php diff --git a/e_lib/adodb5/perf/perf-mssql.inc.php b/vendor/adodb/adodb-php/perf/perf-mssql.inc.php similarity index 100% rename from e_lib/adodb5/perf/perf-mssql.inc.php rename to vendor/adodb/adodb-php/perf/perf-mssql.inc.php diff --git a/e_lib/adodb5/perf/perf-mssqlnative.inc.php b/vendor/adodb/adodb-php/perf/perf-mssqlnative.inc.php similarity index 100% rename from e_lib/adodb5/perf/perf-mssqlnative.inc.php rename to vendor/adodb/adodb-php/perf/perf-mssqlnative.inc.php diff --git a/e_lib/adodb5/perf/perf-mysql.inc.php b/vendor/adodb/adodb-php/perf/perf-mysql.inc.php similarity index 100% rename from e_lib/adodb5/perf/perf-mysql.inc.php rename to vendor/adodb/adodb-php/perf/perf-mysql.inc.php diff --git a/e_lib/adodb5/perf/perf-oci8.inc.php b/vendor/adodb/adodb-php/perf/perf-oci8.inc.php similarity index 100% rename from e_lib/adodb5/perf/perf-oci8.inc.php rename to vendor/adodb/adodb-php/perf/perf-oci8.inc.php diff --git a/e_lib/adodb5/perf/perf-postgres.inc.php b/vendor/adodb/adodb-php/perf/perf-postgres.inc.php similarity index 100% rename from e_lib/adodb5/perf/perf-postgres.inc.php rename to vendor/adodb/adodb-php/perf/perf-postgres.inc.php diff --git a/e_lib/adodb5/pivottable.inc.php b/vendor/adodb/adodb-php/pivottable.inc.php similarity index 100% rename from e_lib/adodb5/pivottable.inc.php rename to vendor/adodb/adodb-php/pivottable.inc.php diff --git a/vendor/adodb/adodb-php/replicate/adodb-replicate.inc.php b/vendor/adodb/adodb-php/replicate/adodb-replicate.inc.php new file mode 100644 index 00000000..9aaf3c42 --- /dev/null +++ b/vendor/adodb/adodb-php/replicate/adodb-replicate.inc.php @@ -0,0 +1,1181 @@ +compat. If compat set to 1.0, then $lastUpdateFld not used during MergeData. + +1.0 Apr 2009 +Added support for MFFA + +0.9 ? 2008 +First release + + + Note: this code assumes that comments such as / * * / ar`e allowed which works with: + Note: this code assumes that comments such as / * * / are allowed which works with: + mssql, postgresql, oracle, mssql + + Replication engine to + - copy table structures and data from different databases (e.g. mysql to oracle) + for replication purposes + - generate CREATE TABLE, CREATE INDEX, INSERT ... for installation scripts + + Table Structure copying includes + - fields and limited subset of types + - optional default values + - indexes + - but not constraints + + + Two modes of data copy: + + ReplicateData + - Copy from src to dest, with update of status of copy back to src, + with configurable src SELECT where clause + + MergeData + - Copy from src to dest based on last mod date field and/or copied flag field + + Default settings are + - do not execute, generate sql ($rep->execute = false) + - do not delete records in dest table first ($rep->deleteFirst = false). + if $rep->deleteFirst is true and primary keys are defined, + then no deletion will occur unless *INSERTONLY* is defined in pkey array + - only commit once at the end of every ReplicateData ($rep->commitReplicate = true) + - do not autocommit every x records processed ($rep->commitRecs = -1) + - even if error occurs on one record, continue copying remaining records ($rep->neverAbort = true) + - debugging turned off ($rep->debug = false) +*/ + +class ADODB_Replicate { + var $connSrc; + var $connDest; + + var $connSrc2 = false; + var $connDest2 = false; + var $ddSrc; + var $ddDest; + + var $execute = false; + var $debug = false; + var $deleteFirst = false; + var $commitReplicate = true; // commit at end of replicatedata + var $commitRecs = -1; // only commit at end of ReplicateData() + + var $selFilter = false; + var $fieldFilter = false; + var $indexFilter = false; + var $updateFilter = false; + var $insertFilter = false; + var $updateSrcFn = false; + + var $limitRecs = false; + + var $neverAbort = true; + var $copyTableDefaults = false; // turn off because functions defined as defaults will not work when copied + var $errHandler = false; // name of error handler function, if used. + var $htmlSpecialChars = true; // if execute false, then output with htmlspecialchars enabled. + // Will autoconfigure itself. No need to modify + + var $trgSuffix = '_mrgTr'; + var $idxSuffix = '_mrgidx'; + var $trLogic = '1 = 1'; + var $datesAreTimeStamps = false; + + var $oracleSequence = false; + var $readUncommitted = false; // read without obeying shared locks for fast select (mssql) + + var $compat = false; + // connSrc2 and connDest2 are only required if the db driver + // does not allow updates back to src db in first connection (the select connection), + // so we need 2nd connection + function __construct($connSrc, $connDest, $connSrc2=false, $connDest2=false) + { + + if (strpos($connSrc->databaseType,'odbtp') !== false) { + $connSrc->_bindInputArray = false; # bug in odbtp, binding fails + } + + if (strpos($connDest->databaseType,'odbtp') !== false) { + $connDest->_bindInputArray = false; # bug in odbtp, binding fails + } + + $this->connSrc = $connSrc; + $this->connDest = $connDest; + + $this->connSrc2 = ($connSrc2) ? $connSrc2 : $connSrc; + $this->connDest2 = ($connDest2) ? $connDest2 : $connDest; + + $this->ddSrc = NewDataDictionary($connSrc); + $this->ddDest = NewDataDictionary($connDest); + $this->htmlSpecialChars = isset($_SERVER['HTTP_HOST']); + } + + function ExecSQL($sql) + { + if (!is_array($sql)) $sql[] = $sql; + + $ret = true; + foreach($sql as $s) + if (!$this->execute) echo "
",$s.";\n
"; + else { + $ok = $this->connDest->Execute($s); + if (!$ok) + if ($this->neverAbort) $ret = false; + else return false; + } + + return $ret; + } + + /* + We assume replication between $table and $desttable only works if the field names and types match for both tables. + + Also $table and desttable can have different names. + */ + + function CopyTableStruct($table,$desttable='') + { + $sql = $this->CopyTableStructSQL($table,$desttable); + if (empty($sql)) return false; + return $this->ExecSQL($sql); + } + + function RunFieldFilter(&$fld, $mode = '') + { + if ($this->fieldFilter) { + $fn = $this->fieldFilter; + return $fn($fld, $mode); + } else + return $fld; + } + + function RunUpdateFilter($table, $fld, $val) + { + if ($this->updateFilter) { + $fn = $this->updateFilter; + return $fn($table, $fld, $val); + } else + return $val; + } + + function RunInsertFilter($table, $fld, &$val) + { + if ($this->insertFilter) { + $fn = $this->insertFilter; + return $fn($table, $fld, $val); + } else + return $fld; + } + + /* + $mode = INS or UPD + + The lastUpdateFld holds the field that counts the number of updates or the date of last mod. This ensures that + if the rec was modified after replicatedata retrieves the data but before we update back the src record, + we don't set the copiedflag='Y' yet. + */ + function RunUpdateSrcFn($srcdb, $table, $fldoffsets, $row, $where, $mode, $dest_insertid=null, $lastUpdateFld='') + { + if (!$this->updateSrcFn) return; + + $bindarr = array(); + foreach($fldoffsets as $k) { + $bindarr[$k] = $row[$k]; + } + $last = sizeof($row); + + if ($lastUpdateFld && $row[$last-1]) { + $ds = $row[$last-1]; + if (strpos($ds,':') !== false) $s = $srcdb->DBTimeStamp($ds); + else $s = $srcdb->qstr($ds); + $where = "WHERE $lastUpdateFld = $s and $where"; + } else + $where = "WHERE $where"; + $fn = $this->updateSrcFn; + if (is_array($fn)) { + if (sizeof($fn) == 1) $set = reset($fn); + else $set = @$fn[$mode]; + if ($set) { + + if (strlen($dest_insertid) == 0) $dest_insertid = 'null'; + $set = str_replace('$INSERT_ID',$dest_insertid,$set); + + $sql = "UPDATE $table SET $set $where "; + $ok = $srcdb->Execute($sql,$bindarr); + if (!$ok) { + echo $srcdb->ErrorMsg(),"
\n"; + die(); + } + } + } else $fn($srcdb, $table, $row, $where, $bindarr, $mode, $dest_insertid); + + } + + function CopyTableStructSQL($table, $desttable='',$dropdest =false) + { + if (!$desttable) { + $desttable = $table; + $prefixidx = ''; + } else + $prefixidx = $desttable; + + $conn = $this->connSrc; + $types = $conn->MetaColumns($table); + if (!$types) { + echo "$table does not exist in source db
\n"; + return array(); + } + if (!$dropdest && $this->connDest->MetaColumns($desttable)) { + echo "$desttable already exists in dest db
\n"; + return array(); + } + if ($this->debug) var_dump($types); + $sa = array(); + $idxcols = array(); + + foreach($types as $name => $t) { + $s = ''; + $mt = $this->ddSrc->MetaType($t->type); + $len = $t->max_length; + $fldname = $this->RunFieldFilter($t->name,'TABLE'); + if (!$fldname) continue; + + $s .= $fldname . ' '.$mt; + if (isset($t->scale)) $precision = '.'.$t->scale; + else $precision = ''; + if ($mt == 'C' or $mt == 'X') $s .= "($len)"; + else if ($mt == 'N' && $precision) $s .= "($len$precision)"; + + if ($mt == 'R') $idxcols[] = $fldname; + + if ($this->copyTableDefaults) { + if (isset($t->default_value)) { + $v = $t->default_value; + if ($mt == 'C' or $mt == 'X') $v = $this->connDest->qstr($v); // might not work as this could be function + $s .= ' DEFAULT '.$v; + } + } + + $sa[] = $s; + } + + $s = implode(",\n",$sa); + + // dump adodb intermediate data dictionary format + if ($this->debug) echo '
'.$s.'
'; + + $sqla = $this->ddDest->CreateTableSQL($desttable,$s); + + /* + if ($idxcols) { + $idxoptions = array('UNIQUE'=>1); + $sqla2 = $this->ddDest->_IndexSQL($table.'_'.$fldname.'_SERIAL', $desttable, $idxcols,$idxoptions); + $sqla = array_merge($sqla,$sqla2); + }*/ + + $idxs = $conn->MetaIndexes($table); + if ($idxs) + foreach($idxs as $name => $iarr) { + $idxoptions = array(); + $fldnames = array(); + + if(!empty($iarr['unique'])) { + $idxoptions['UNIQUE'] = 1; + } + + foreach($iarr['columns'] as $fld) { + $fldnames[] = $this->RunFieldFilter($fld,'TABLE'); + } + + $idxname = $prefixidx.str_replace($table,$desttable,$name); + + if (!empty($this->indexFilter)) { + $fn = $this->indexFilter; + $idxname = $fn($desttable,$idxname,$fldnames,$idxoptions); + } + $sqla2 = $this->ddDest->_IndexSQL($idxname, $desttable, $fldnames,$idxoptions); + $sqla = array_merge($sqla,$sqla2); + } + + return $sqla; + } + + function _clearcache() + { + + } + + function _concat($v) + { + return $this->connDest->concat("' ","chr(".ord($v).")","'"); + } + + function fixupbinary($v) + { + return str_replace( + array("\r","\n"), + array($this->_concat("\r"),$this->_concat("\n")), + $v ); + } + + function SwapDBs() + { + $o = $this->connSrc; + $this->connSrc = $this->connDest; + $this->connDest = $o; + + + $o = $this->connSrc2; + $this->connSrc2 = $this->connDest2; + $this->connDest2 = $o; + + $o = $this->ddSrc; + $this->ddSrc = $this->ddDest; + $this->ddDest = $o; + } + + /* + // if no uniqflds defined, then all desttable recs will be deleted before insert + // $where clause must include the WHERE word if used + // if $this->commitRecs is set to a +ve value, then it will autocommit every $this->commitRecs records + // -- this should never be done with 7x24 db's + + Returns an array: + $arr[0] = true if no error, false if error + $arr[1] = number of recs processed + $arr[2] = number of successful inserts + $arr[3] = number of successful updates + + ReplicateData() params: + + $table = src table name + $desttable = dest table name, leave blank to use src table name + $uniqflds = array() = an array. If set, then inserts and updates will occur. eg. array('PK1', 'PK2'); + To prevent updates to desttable (allow only to src table), add '*INSERTONLY*' or '*ONLYINSERT*' to array. + + Sometimes you are replicating a src table with an autoinc primary key. + You sometimes create recs in the dest table. The dest table has to retrieve the + src table's autoinc key (stored in a 2nd field) so you can match the two tables. + + To define this, and the uniqflds contains nested arrays. Copying from autoinc table to other table: + array(array($destpkey), array($destfld_holds_src_autoinc_pkey)) + + Copying from normal table to autoinc table: + array(array($destpkey), array(), array($srcfld_holds_dest_autoinc_pkey)) + + $where = where clause for SELECT from $table $where. Include the WHERE reserved word in beginning. + You can put ORDER BY at the end also + $ignoreflds = array(), list of fields to ignore. e.g. array('FLD1',FLD2'); + $dstCopyDateFld = date field on $desttable to update with current date + $extraflds allows you to add additional flds to insert/update. Format + array(fldname => $fldval) + $fldval itself can be an array or a string. If an array, then + $extraflds = array($fldname => array($insertval, $updateval)) + + Thus we have the following behaviours: + + a. Delete all data in $desttable then insert from src $table + + $rep->execute = true; + $rep->ReplicateData($table, $desttable) + + b. Update $desttable if record exists (based on $uniqflds), otherwise insert. + + $rep->execute = true; + $rep->ReplicateData($table, $desttable, $array($pkey1, $pkey2)) + + c. Select from src $table all data modified since a date. Then update $desttable + if record exists (based on $uniqflds), otherwise insert + + $rep->execute = true; + $rep->ReplicateData($table, $desttable, array($pkey1, $pkey2), "WHERE update_datetime_fld > $LAST_REFRESH") + + d. Insert all records into $desttable modified after a certain id (or time) in src $table: + + $rep->execute = true; + $rep->ReplicateData($table, $desttable, false, "WHERE id_fld > $LAST_ID_SAVED", true); + + + For (a) to (d), returns array: array($boolean_ok_fail, $no_recs_selected_from_src_db, $no_recs_inserted, $no_recs_updated); + + e. Generate sample SQL: + + $rep->execute = false; + $rep->ReplicateData(....); + + This returns $array, which contains: + + $array['SEL'] = select stmt from src db + $array['UPD'] = update stmt to dest db + $array['INS'] = insert stmt to dest db + + + Error-handling + ============== + Default is never abort if error occurs. You can set $rep->neverAbort = false; to force replication to abort if an error occurs. + + + Value Filtering + ======== + Sometimes you might need to modify/massage the data before the code works. Assume that the value used for True and False is + 'T' and 'F' in src DB, but is 'Y' and 'N' in dest DB for field[2] in select stmt. You can do this by + + $rep->filterSelect = 'filter'; + $rep->ReplicateData(...); + + function filter($table,& $fields, $deleteFirst) + { + if ($table == 'SOMETABLE') { + if ($fields[2] == 'T') $fields[2] = 'Y'; + else if ($fields[2] == 'F') $fields[2] = 'N'; + } + } + + We pass in $deleteFirst as that determines the order of the fields (which are numeric-based): + TRUE: the order of fields matches the src table order + FALSE: the order of fields is all non-primary key fields first, followed by primary key fields. This is because it needs + to match the UPDATE statement, which is UPDATE $table SET f2 = ?, f3 = ? ... WHERE f1 = ? + + Name Filtering + ========= + Sometimes field names that are legal in one RDBMS can be illegal in another. + We allow you to handle this using a field filter. + Also if you don't want to replicate certain fields, just return false. + + $rep->fieldFilter = 'ffilter'; + + function ffilter(&$fld,$mode) + { + $uf = strtoupper($fld); + switch($uf) { + case 'GROUP': + if ($mode == 'SELECT') $fld = '"Group"'; + return 'GroupFld'; + + case 'PRIVATEFLD': # do not replicate + return false; + } + return $fld; + } + + + UPDATE FILTERING + ================ + Sometimes, when we want to update + UPDATE table SET fld = val WHERE .... + + we want to modify val. To do so, define + + $rep->updateFilter = 'ufilter'; + + function ufilter($table, $fld, $val) + { + return "nvl($fld, $val)"; + } + + + Sending back audit info back to src Table + ========================================= + + Use $rep->updateSrcFn. This can be an array of strings, or the name of a php function to call. + + If an array of strings is defined, then it will perform an update statement... + + UPDATE srctable SET $string WHERE .... + + With $string set to the array you define. If a new record was inserted into desttable, then the + 'INS' string is used ($INSERT_ID will be replaced with the real INSERT_ID, if any), + and if an update then use the 'UPD' string. + + array( + 'INS' => 'insertid = $INSERT_ID, copieddate=getdate(), copied = 1', + 'UPD' => 'copieddate=getdate(), copied = 1' + ) + + If a single string array is defined, then it will be used for both insert and update. + array('copieddate=getdate(), copied = 1') + + Note that the where clause is automatically defined by the system. + + If $rep->updateSrcFn is a PHP function name, then it will be called with the following params: + + $fn($srcConnection, $tableName, $row, $where, $bindarr, $mode, $dest_insertid) + + $srcConnection - source db connection + $tableName - source tablename + $row - array holding records updated into dest + $where - where clause to be used (uses bind vars) + $bindarr - array holding bind variables for where clause + $mode - INS or UPD + $dest_insertid - when mode=INS, then the insert_id is stored here. + + + oracle mssql + ---> insert + mssqlid <--- insert_id + ----> update with mssqlid + <---- update with mssqlid + + + TODO: add src pkey and dest pkey for updates. Also sql stmt needs to be tuned, so dest pkey, src pkey + */ + + + function ReplicateData($table, $desttable = '', $uniqflds = array(), $where = '',$ignore_flds = array(), + $dstCopyDateFld='', $extraflds = array(), $lastUpdateFld = '') + { + if (is_array($where)) { + $wheresrc = $where[0]; + $wheredest = $where[1]; + } else { + $wheresrc = $wheredest = $where; + } + $dstCopyDateName = $dstCopyDateFld; + $dstCopyDateFld = strtoupper($dstCopyDateFld); + + $this->_clearcache(); + if (is_string($uniqflds) && strlen($uniqflds)) $uniqflds = array($uniqflds); + if (!$desttable) $desttable = $table; + + $uniq = array(); + if ($uniqflds) { + if (is_array(reset($uniqflds))) { + /* + primary key of src and dest tables differ. This means when we perform the select stmts + we retrieve both keys. Then any insert statement will have to ignore one array element. + Any update statement will need to use a different where clause + */ + $destuniqflds = $uniqflds[0]; + if (sizeof($uniqflds)>1 && $uniqflds[1]) // srckey field name in dest table + $srcuniqflds = $uniqflds[1]; + else + $srcuniqflds = array(); + + if (sizeof($uniqflds)>2) + $srcPKDest = reset($uniqflds[2]); + + } else { + $destuniqflds = $uniqflds; + $srcuniqflds = array(); + } + $onlyInsert = false; + foreach($destuniqflds as $k => $u) { + if ($u == '*INSERTONLY*' || $u == '*ONLYINSERT*') { + $onlyInsert = true; + continue; + } + $uniq[strtoupper($u)] = $k; + } + $deleteFirst = $this->deleteFirst; + } else { + $deleteFirst = true; + } + + if ($deleteFirst) $onlyInsert = true; + + if ($ignore_flds) { + foreach($ignore_flds as $u) { + $ignoreflds[strtoupper($u)] = 1; + } + } else + $ignoreflds = array(); + + $src = $this->connSrc; + $dest = $this->connDest; + $src2 = $this->connSrc2; + + $dest->noNullStrings = false; + $src->noNullStrings = false; + $src2->noNullStrings = false; + + if ($src === $dest) $this->execute = false; + + $types = $src->MetaColumns($table); + if (!$types) { + echo "Source $table does not exist
\n"; + return array(); + } + $dtypes = $dest->MetaColumns($desttable); + if (!$dtypes) { + echo "Destination $desttable does not exist
\n"; + return array(); + } + $sa = array(); + $selflds = array(); + $wheref = array(); + $wheres = array(); + $srcwheref = array(); + $fldoffsets = array(); + $k = 0; + foreach($types as $name => $t) { + $name2 = strtoupper($this->RunFieldFilter($name,'SELECT')); + // handle quotes + if ($name2 && $name2[0] == '"' && $name2[strlen($name2)-1] == '"') $name22 = substr($name2,1,strlen($name2)-2); + elseif ($name2 && $name2[0] == '`' && $name2[strlen($name2)-1] == '`') $name22 = substr($name2,1,strlen($name2)-2); + else $name22 = $name2; + + //else $name22 = $name2; // this causes problem for quotes strip above + + if (!isset($dtypes[($name22)]) || !$name2) { + if ($this->debug) echo " Skipping $name ==> $name2 as not in destination $desttable
"; + continue; + } + + if ($name2 == $dstCopyDateFld) { + $dstCopyDateName = $t->name; + continue; + } + + $fld = $t->name; + $fldval = $t->name; + $mt = $src->MetaType($t->type); + if ($this->datesAreTimeStamps && $mt == 'D') $mt = 'T'; + if ($mt == 'D') $fldval = $dest->DBDate($fldval); + elseif ($mt == 'T') $fldval = $dest->DBTimeStamp($fldval); + $ufld = strtoupper($fld); + + if (isset($ignoreflds[($name2)]) && !isset($uniq[$ufld])) { + continue; + } + + if ($this->debug) echo " field=$fld type=$mt fldval=$fldval
"; + + if (!isset($uniq[$ufld])) { + + $selfld = $fld; + $fld = $this->RunFieldFilter($selfld,'SELECT'); + $selflds[] = $selfld; + + $p = $dest->Param($k); + + if ($mt == 'D') $p = $dest->DBDate($p, true); + else if ($mt == 'T') $p = $dest->DBTimeStamp($p, true); + + # UPDATES + $sets[] = "$fld = ".$this->RunUpdateFilter($desttable, $fld, $p); + + # INSERTS + $insflds[] = $this->RunInsertFilter($desttable,$fld, $p); $params[] = $p; + $k++; + } else { + $fld = $this->RunFieldFilter($fld); + $wheref[] = $fld; + if (!empty($srcuniqflds)) $srcwheref[] = $srcuniqflds[$uniq[$ufld]]; + if ($mt == 'C') { # normally we don't include the primary key in the insert if it is numeric, but ok if varchar + $insertpkey = true; + } + } + } + + + foreach($extraflds as $fld => $evals) { + if (!is_array($evals)) $evals = array($evals, $evals); + $insflds[] = $this->RunInsertFilter($desttable,$fld, $p); $params[] = $evals[0]; + $sets[] = "$fld = ".$evals[1]; + } + + if ($dstCopyDateFld) { + $sets[] = "$dstCopyDateName = ".$dest->sysTimeStamp; + $insflds[] = $this->RunInsertFilter($desttable,$dstCopyDateName, $p); $params[] = $dest->sysTimeStamp; + } + + + if (!empty($srcPKDest)) { + $selflds[] = $srcPKDest; + $fldoffsets = array($k+1); + } + + foreach($wheref as $uu => $fld) { + + $p = $dest->Param($k); + $sp = $src->Param($k); + if (!empty($srcuniqflds)) { + if ($uu > 1) die("Only one primary key for srcuniqflds allowed currently"); + $destsrckey = reset($srcuniqflds); + $wheres[] = reset($srcuniqflds).' = '.$p; + + $insflds[] = $this->RunInsertFilter($desttable,$destsrckey, $p); + $params[] = $p; + } else { + $wheres[] = $fld.' = '.$p; + if (!isset($ignoreflds[strtoupper($fld)]) || !empty($insertpkey)) { + $insflds[] = $this->RunInsertFilter($desttable,$fld, $p); + $params[] = $p; + } + } + + $selflds[] = $fld; + $srcwheres[] = $fld.' = '.$sp; + $fldoffsets[] = $k; + + $k++; + } + + if (!empty($srcPKDest)) { + $fldoffsets = array($k); + $srcwheres = array($fld.'='.$src->Param($k)); + $k++; + } + + if ($lastUpdateFld) { + $selflds[] = $lastUpdateFld; + } else + $selflds[] = 'null as Z55_DUMMY_LA5TUPD'; + + $insfldss = implode(', ', $insflds); + $fldss = implode(', ', $selflds); + $setss = implode(', ', $sets); + $paramss = implode(', ', $params); + $wheress = implode(' AND ', $wheres); + if (isset($srcwheres)) + $srcwheress = implode(' AND ',$srcwheres); + + + $seltable = $table; + if ($this->readUncommitted && strpos($src->databaseType,'mssql')) $seltable .= ' with (NOLOCK)'; + + $sa['SEL'] = "SELECT $fldss FROM $seltable $wheresrc"; + $sa['INS'] = "INSERT INTO $desttable ($insfldss) VALUES ($paramss) /**INS**/"; + $sa['UPD'] = "UPDATE $desttable SET $setss WHERE $wheress /**UPD**/"; + + + + $DB1 = "/* Source DB - sample sql in case you need to adapt code\n\n"; + $DB2 = "/* Dest DB - sample sql in case you need to adapt code\n\n"; + + if (!$this->execute) echo '/*
*/
+';
+		if ($deleteFirst && $this->deleteFirst) {
+			$where = preg_replace('/[ \n\r\t]+order[ \n\r\t]+by.*$/i', '', $where);
+			$sql = "DELETE FROM $desttable $wheredest\n";
+			if (!$this->execute) echo $DB2,'*/',$sql,"\n";
+			else $dest->Execute($sql);
+		}
+
+		global $ADODB_COUNTRECS;
+		$err = false;
+		$savemode = $src->setFetchMode(ADODB_FETCH_NUM);
+		$ADODB_COUNTRECS = false;
+
+		if (!$this->execute) {
+			echo $DB1,$sa['SEL'],"\n*/\n\n";
+			echo $DB2,$sa['INS'],"\n*/\n\n";
+			$suffix = ($onlyInsert) ? ' PRIMKEY=?' : '';
+			echo $DB2,$sa['UPD'],"$suffix\n*/\n\n";
+
+			$rs = $src->Execute($sa['SEL']);
+			$cnt = 1;
+			$upd = 0;
+			$ins = 0;
+
+			$sqlarr = explode('?',$sa['INS']);
+			$nparams = sizeof($sqlarr)-1;
+
+			$useQmark = $dest && ($dest->dataProvider != 'oci8');
+
+			while ($rs && !$rs->EOF) {
+				if ($useQmark) {
+					$sql = ''; $i = 0;
+					$arr = array_reverse($rs->fields);
+					//Use each() instead of foreach to reduce memory usage -mikefedyk
+					while(list(, $v) = each($arr)) {
+						$sql .= $sqlarr[$i];
+						// from Ron Baldwin 
+						// Only quote string types
+						$typ = gettype($v);
+						if ($typ == 'string')
+							//New memory copy of input created here -mikefedyk
+							$sql .= $dest->qstr($v);
+						else if ($typ == 'double')
+							$sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1
+						else if ($typ == 'boolean')
+							$sql .= $v ? $dest->true : $dest->false;
+						else if ($typ == 'object') {
+							if (method_exists($v, '__toString')) $sql .= $dest->qstr($v->__toString());
+							else $sql .= $dest->qstr((string) $v);
+						} else if ($v === null)
+							$sql .= 'NULL';
+						else
+							$sql .= $v;
+						$i += 1;
+
+						if ($i == $nparams) break;
+					} // while
+
+					if (isset($sqlarr[$i])) {
+						$sql .= $sqlarr[$i];
+					}
+					$INS = $sql;
+				} else {
+					$INS = $sa['INS'];
+					$arr = array_reverse($rs->fields);
+					foreach($arr as $k => $v) { // only works on oracle currently
+						$k = sizeof($arr)-$k-1;
+						$v = str_replace(":","%~%COLON%!%",$v);
+						$INS = str_replace(':'.$k,$this->fixupbinary($dest->qstr($v)),$INS);
+					}
+					$INS = str_replace("%~%COLON%!%",":",$INS);
+					if ($this->htmlSpecialChars) $INS = htmlspecialchars($INS);
+				}
+				echo "-- $cnt\n",$INS,";\n\n";
+				$cnt += 1;
+				$ins += 1;
+				$rs->MoveNext();
+			}
+			$src->setFetchMode($savemode);
+			return $sa;
+		} else {
+			$saved = $src->debug;
+			#$src->debug=1;
+			if ($this->limitRecs>100)
+				$rs = $src->SelectLimit($sa['SEL'],$this->limitRecs);
+			else
+				$rs = $src->Execute($sa['SEL']);
+			$src->debug = $saved;
+			if (!$rs) {
+				if ($this->errHandler) $this->_doerr('SEL',array());
+				return array(0,0,0,0);
+			}
+
+
+			if ($this->commitReplicate || $commitRecs > 0) {
+				$dest->BeginTrans();
+				if ($this->updateSrcFn) $src2->BeginTrans();
+			}
+
+			if ($this->updateSrcFn && strpos($src2->databaseType,'mssql') !== false) {
+				# problem is writers interfere with readers in mssql
+				$rs = $src->_rs2rs($rs);
+			}
+			$cnt = 0;
+			$upd = 0;
+			$ins = 0;
+
+			$sizeofrow = sizeof($selflds);
+
+			$fn = $this->selFilter;
+			$commitRecs = $this->commitRecs;
+
+			$saved = $dest->debug;
+
+			if ($this->deleteFirst) $onlyInsert = true;
+			while ($origrow = $rs->FetchRow()) {
+
+				if ($dest->debug) {flush(); @ob_flush();}
+
+				if ($fn) {
+					if (!$fn($desttable, $origrow, $deleteFirst, $this, $selflds)) continue;
+				}
+				$doinsert = true;
+				$row = array_slice($origrow,0,$sizeofrow-1);
+
+				if (!$onlyInsert) {
+					$doinsert = false;
+					$upderr = false;
+
+					if (isset($srcPKDest)) {
+						if (is_null($origrow[$sizeofrow-3])) {
+							$doinsert = true;
+							$upderr = true;
+						}
+					}
+					if (!$upderr && !$dest->Execute($sa['UPD'],$row)) {
+						$err = true;
+						$upderr = true;
+						if ($this->errHandler) $this->_doerr('UPD',$row);
+						if (!$this->neverAbort) break;
+					}
+
+				 	if ($upderr || $dest->Affected_Rows() == 0) {
+						$doinsert = true;
+					} else {
+						if (!empty($uniqflds)) $this->RunUpdateSrcFn($src2, $table, $fldoffsets, $origrow, $srcwheress, 'UPD', null, $lastUpdateFld);
+						$upd += 1;
+					}
+				}
+
+				if ($doinsert) {
+					$inserr = false;
+					if (isset($srcPKDest)) {
+						$row = array_slice($origrow,0,$sizeofrow-2);
+					}
+
+					if (! $dest->Execute($sa['INS'],$row)) {
+						$err = true;
+						$inserr = true;
+						if ($this->errHandler) $this->_doerr('INS',$row);
+						if ($this->neverAbort) continue;
+						else break;
+					} else {
+						if ($dest->dataProvider == 'oci8') {
+							if ($this->oracleSequence) $lastid = $dest->GetOne("select ".$this->oracleSequence.".currVal from dual");
+						 	else $lastid = 'null';
+						} else {
+							$lastid = $dest->Insert_ID();
+						}
+
+						if (!$inserr && !empty($uniqflds)) {
+							$this->RunUpdateSrcFn($src2, $table, $fldoffsets, $origrow, $srcwheress, 'INS', $lastid,$lastUpdateFld);
+						}
+						$ins += 1;
+					}
+				}
+				$cnt += 1;
+
+				if ($commitRecs > 0 && ($cnt % $commitRecs) == 0) {
+					$dest->CommitTrans();
+					$dest->BeginTrans();
+
+					if ($this->updateSrcFn) {
+						$src2->CommitTrans();
+						$src2->BeginTrans();
+					}
+				}
+
+			} // while
+
+
+			if ($this->commitReplicate || $commitRecs > 0) {
+				if (!$this->neverAbort && $err) {
+					$dest->RollbackTrans();
+					if ($this->updateSrcFn) $src2->RollbackTrans();
+				} else {
+					$dest->CommitTrans();
+					if ($this->updateSrcFn) $src2->CommitTrans();
+				}
+			}
+		}
+		if ($cnt != $ins + $upd) echo "

ERROR: $cnt != INS $ins + UPD $upd

"; + $src->setFetchMode($savemode); + return array(!$err, $cnt, $ins, $upd); + } + // trigger support only for sql server and oracle + // need to add + function MergeSrcSetup($srcTable, $pkeys, $srcUpdateDateFld, $srcCopyDateFld, $srcCopyFlagFld, + $srcCopyFlagType='C(1)', $srcCopyFlagVals = array('Y','N','P','=')) + { + $sqla = array(); + $src = $this->connSrc; + $idx = $srcTable.'_mrgIdx'; + $cols = $src->MetaColumns($srcTable); + #adodb_pr($cols); + if (!isset($cols[strtoupper($srcUpdateDateFld)])) { + $sqla = $this->ddSrc->AddColumnSQL($srcTable, "$srcUpdateDateFld TS DEFTIMESTAMP"); + foreach($sqla as $sql) $src->Execute($sql); + } + + if ($srcCopyDateFld && !isset($cols[strtoupper($srcCopyDateFld)])) { + $sqla = $this->ddSrc->AddColumnSQL($srcTable, "$srcCopyDateFld TS DEFTIMESTAMP"); + foreach($sqla as $sql) $src->Execute($sql); + } + + $sysdate = $src->sysTimeStamp; + $arrv0 = $src->qstr($srcCopyFlagVals[0]); + $arrv1 = $src->qstr($srcCopyFlagVals[1]); + $arrv2 = $src->qstr($srcCopyFlagVals[2]); + $arrv3 = $src->qstr($srcCopyFlagVals[3]); + + if ($srcCopyFlagFld && !isset($cols[strtoupper($srcCopyFlagFld)])) { + $sqla = $this->ddSrc->AddColumnSQL($srcTable, "$srcCopyFlagFld $srcCopyFlagType DEFAULT $arrv1"); + foreach($sqla as $sql) $src->Execute($sql); + } + + $sqla = array(); + + + $name = "{$srcTable}_mrgTr"; + if (is_array($pkeys) && strpos($src->databaseType,'mssql') !== false) { + $pk = reset($pkeys); + + #$sqla[] = "DROP TRIGGER $name"; + $sqltr = " + TRIGGER $name + ON $srcTable /* for data replication and merge */ + AFTER UPDATE + AS + UPDATE $srcTable + SET + $srcUpdateDateFld = case when I.$srcCopyFlagFld = $arrv2 or I.$srcCopyFlagFld = $arrv3 then I.$srcUpdateDateFld + else $sysdate end, + $srcCopyFlagFld = case + when I.$srcCopyFlagFld = $arrv2 then $arrv0 + when I.$srcCopyFlagFld = $arrv3 then D.$srcCopyFlagFld + else $arrv1 end + FROM $srcTable S Join Inserted AS I on I.$pk = S.$pk + JOIN Deleted as D ON I.$pk = D.$pk + WHERE I.$srcCopyFlagFld = D.$srcCopyFlagFld or I.$srcCopyFlagFld = $arrv2 + or I.$srcCopyFlagFld = $arrv3 or I.$srcCopyFlagFld is null + "; + $sqla[] = 'CREATE '.$sqltr; // first if does not exists + $sqla[] = 'ALTER '.$sqltr; // second if it already exists + } else if (strpos($src->databaseType,'oci') !== false) { + + if (strlen($srcTable)>22) $tableidx = substr($srcTable,0,16).substr(crc32($srcTable),6); + else $tableidx = $srcTable; + + $name = $tableidx.$this->trgSuffix; + $idx = $tableidx.$this->idxSuffix; + $sqla[] = " +CREATE OR REPLACE TRIGGER $name /* for data replication and merge */ +BEFORE UPDATE ON $srcTable REFERENCING NEW AS NEW OLD AS OLD +FOR EACH ROW +BEGIN + if :new.$srcCopyFlagFld = $arrv2 then + :new.$srcCopyFlagFld := $arrv0; + elsif :new.$srcCopyFlagFld = $arrv3 then + :new.$srcCopyFlagFld := :old.$srcCopyFlagFld; + elsif :old.$srcCopyFlagFld = :new.$srcCopyFlagFld or :new.$srcCopyFlagFld is null then + if $this->trLogic then + :new.$srcUpdateDateFld := $sysdate; + :new.$srcCopyFlagFld := $arrv1; + end if; + end if; +END; +"; + } + foreach($sqla as $sql) $src->Execute($sql); + + if ($srcCopyFlagFld) $srcCopyFlagFld .= ', '; + $src->Execute("CREATE INDEX {$idx} on $srcTable ($srcCopyFlagFld$srcUpdateDateFld)"); + } + + + /* + Perform Merge by copying all data modified from src to dest + then update src copied flag if present. + + Returns array taken from ReplicateData: + + Returns an array: + $arr[0] = true if no error, false if error + $arr[1] = number of recs processed + $arr[2] = number of successful inserts + $arr[3] = number of successful updates + + $srcTable = src table + $dstTable = dest table + $pkeys = primary keys array. if empty, then only inserts will occur + $srcignoreflds = ignore these flds (must be upper cased) + $setsrc = updateSrcFn string + $srcUpdateDateFld = field in src with the last update date + $srcCopyFlagFld = false = optional field that holds the copied indicator + $flagvals=array('Y','N','P','=') = array of values indicating array(copied, not copied). + Null is assumed to mean not copied. The 3rd value 'P' indicates that we want to force 'Y', bypassing + default trigger behaviour to reset the COPIED='N' when the record is replicated from other side. + The last value '=' is don't change copyflag. + $srcCopyDateFld = field that holds last copy date in src table, which will be updated on Merge() + $dstCopyDateFld = field that holds last copy date in dst table, which will be updated on Merge() + $defaultDestRaiseErrorFn = The adodb raiseErrorFn handler. Default is to not raise an error. + Just output error message to stdout + + */ + + + function Merge($srcTable, $dstTable, $pkeys, $srcignoreflds, $setsrc, + $srcUpdateDateFld, + $srcCopyFlagFld, $flagvals=array('Y','N','P','='), + $srcCopyDateFld = false, + $dstCopyDateFld = false, + $whereClauses = '', + $orderBy = '', # MUST INCLUDE THE "ORDER BY" suffix + $copyDoneFlagIdx = 3, + $defaultDestRaiseErrorFn = '') + { + $src = $this->connSrc; + $dest = $this->connDest; + + $time = $src->Time(); + + $delfirst = $this->deleteFirst; + $upd = $this->updateSrcFn; + + $this->deleteFirst = false; + //$this->updateFirst = true; + + $srcignoreflds[] = $srcUpdateDateFld; + $srcignoreflds[] = $srcCopyFlagFld; + $srcignoreflds[] = $srcCopyDateFld; + + if (empty($whereClauses)) $whereClauses = '1=1'; + $where = " WHERE ($whereClauses) and ($srcCopyFlagFld = ".$src->qstr($flagvals[1]).')'; + if ($orderBy) $where .= ' '.$orderBy; + else $where .= ' ORDER BY '.$srcUpdateDateFld; + + if ($setsrc) $set[] = $setsrc; + else $set = array(); + + if ($srcCopyFlagFld) $set[] = "$srcCopyFlagFld = ".$src->qstr($flagvals[2]); + if ($srcCopyDateFld) $set[]= "$srcCopyDateFld = ".$src->sysTimeStamp; + if ($set) $this->updateSrcFn = array(implode(', ',$set)); + else $this->updateSrcFn = ''; + + + $extra[$srcCopyFlagFld] = array($dest->qstr($flagvals[0]),$dest->qstr($flagvals[$copyDoneFlagIdx])); + + $saveraise = $dest->raiseErrorFn; + $dest->raiseErrorFn = ''; + + if ($this->compat && $this->compat == 1.0) $srcUpdateDateFld = ''; + $arr = $this->ReplicateData($srcTable, $dstTable, $pkeys, $where, $srcignoreflds, + $dstCopyDateFld,$extra,$srcUpdateDateFld); + + $dest->raiseErrorFn = $saveraise; + + $this->updateSrcFn = $upd; + $this->deleteFirst = $delfirst; + + return $arr; + } + /* + If doing a 2 way merge, then call + $rep->Merge() + to save without modifying the COPIEDFLAG ('='). + + Then can the following to set the COPIEDFLAG to 'P' which forces the COPIEDFLAG = 'Y' + $rep->MergeDone() + */ + + function MergeDone($srcTable, $dstTable, $pkeys, $srcignoreflds, $setsrc, + $srcUpdateDateFld, + $srcCopyFlagFld, $flagvals=array('Y','N','P','='), + $srcCopyDateFld = false, + $dstCopyDateFld = false, + $whereClauses = '', + $orderBy = '', # MUST INCLUDE THE "ORDER BY" suffix + $copyDoneFlagIdx = 2, + $defaultDestRaiseErrorFn = '') + { + return $this->Merge($srcTable, $dstTable, $pkeys, $srcignoreflds, $setsrc, + $srcUpdateDateFld, + $srcCopyFlagFld, $flagvals, + $srcCopyDateFld, + $dstCopyDateFld, + $whereClauses, + $orderBy, # MUST INCLUDE THE "ORDER BY" suffix + $copyDoneFlagIdx, + $defaultDestRaiseErrorFn); + } + + function _doerr($reason, $selflds) + { + $fn = $this->errHandler; + if ($fn) $fn($this, $reason, $selflds); // set $this->neverAbort to true or false as required inside $fn + } +} diff --git a/vendor/adodb/adodb-php/replicate/replicate-steps.php b/vendor/adodb/adodb-php/replicate/replicate-steps.php new file mode 100644 index 00000000..5b696568 --- /dev/null +++ b/vendor/adodb/adodb-php/replicate/replicate-steps.php @@ -0,0 +1,137 @@ +Connect($HOST,$USER,$PWD,$DBASE); +if (!$ok) return; + + +#$DB->debug=1; + +$bkup = 'tmp'.date('ymd_His'); + + +if ($BA) { + $QTY_BA = " and qu_bacode='$BA'"; + if (1) $STP_BA = " and s_stagecat in (select stg_stagecat from kbstage where stg_bacode='$BA')"; # OLDER KBSTEP + else $STP_BA = " and s_bacode='$BA'"; # LATEST KBSTEP format + $STG_BA = " and stg_bacode='$BA'"; +} else { + $QTY_BA = ""; + $STP_BA = ""; + $STG_BA = ""; +} + +if ($STAGES) { + + $STAGES = explode(',',$STAGES); + $STAGES = "'".implode("','",$STAGES)."'"; + $QTY_STG = " and qu_stagecat in ($STAGES)"; + $STP_STG = " and s_stagecat in ($STAGES)"; + $STG_STG = " and stg_stagecat in ($STAGES)"; +} else { + $QTY_STG = ""; + $STP_STG = ""; + $STG_STG = ""; +} + +echo "
+
+/******************************************************************************
+
+ Migrate stages, steps and qtypes for the following
+
+  business area: $BA
+     and stages: $STAGES
+
+
+ WARNING: DO NOT 'Ignore All Errors'.
+ If any error occurs, make sure you stop and check the reason and fix it.
+ Otherwise you could corrupt everything!!!
+
+ Connected to $USER@$DBASE $HOST;
+
+*******************************************************************************/
+
+-- BACKUP
+create table kbstage_$bkup as select * from kbstage;
+create table kbstep_$bkup as select * from kbstep;
+create table kbqtype_$bkup as select * from kbqtype;
+
+
+-- IF CODE FAILS, REMEMBER TO RENABLE ALL TRIGGERS and following CONSTRAINT
+ALTER TABLE kbstage DISABLE all triggers;
+ALTER TABLE kbstep DISABLE all triggers;
+ALTER TABLE kbqtype DISABLE all triggers;
+ALTER TABLE jqueue DISABLE CONSTRAINT QUEUE_MUST_HAVE_TYPE;
+
+
+-- NOW DELETE OLD STEPS/STAGES/QUEUES
+delete from kbqtype where qu_mode in ('STAGE','STEP') $QTY_BA $QTY_STG;
+delete from kbstep where (1=1) $STP_BA$STP_STG;
+delete from kbstage where (1=1)$STG_BA$STG_STG;
+
+
+
+SET DEFINE OFF; -- disable  variable handling by sqlplus
+/
+/* Assume kbstrategy and business areas are compatible for steps and stages to be copied */
+
+ +"; + + +$rep = new ADODB_Replicate($DB,$DB); +$rep->execute = false; +$rep->deleteFirst = false; + + // src table name, dst table name, primary key, where condition +$rep->ReplicateData('KBSTAGE', 'KBSTAGE', array(), " where (1=1)$STG_BA$STG_STG"); +$rep->ReplicateData('KBSTEP', 'KBSTEP', array(), " where (1=1)$STP_BA$STP_STG"); +$rep->ReplicateData('KBQTYPE','KBQTYPE',array()," where qu_mode in ('STAGE','STEP')$QTY_BA$QTY_STG"); + +echo " + +-- Check for QUEUES not in KBQTYPE and FIX by copying from kbqtype_$bkup +begin +for rec in (select distinct q_type from jqueue where q_type not in (select qu_code from kbqtype)) loop + insert into kbqtype select * from kbqtype_$bkup where qu_code = rec.q_type; + update kbqtype set qu_name=substr('MISSING.'||qu_name,1,64) where qu_code=rec.q_type; +end loop; +end; +/ + +commit; + + +ALTER TABLE kbstage ENABLE all triggers; +ALTER TABLE kbstep ENABLE all triggers; +ALTER TABLE kbqtype ENABLE all triggers; +ALTER TABLE jqueue ENABLE CONSTRAINT QUEUE_MUST_HAVE_TYPE; + +/* +-- REMEMBER TO COMMIT + commit; + begin Juris.UpdateQCounts; end; + +-- To check for bad queues after conversion, run this + select * from kbqtype where qu_name like 'MISSING%' +*/ +/ +"; diff --git a/vendor/adodb/adodb-php/replicate/test-tnb.php b/vendor/adodb/adodb-php/replicate/test-tnb.php new file mode 100644 index 00000000..f163ff4f --- /dev/null +++ b/vendor/adodb/adodb-php/replicate/test-tnb.php @@ -0,0 +1,421 @@ + 28) $idxname = substr($idxname,0,24).rand(1000,9999); + return $idxname; +} + +function SelFilter($table, &$arr, $delfirst) +{ + return true; +} + +function updatefilter($table, $fld, $val) +{ + return "nvl($fld, $val)"; +} + + +function FieldFilter(&$fld,$mode) +{ + $uf = strtoupper($fld); + switch($uf) { + case 'SIZEFLD': + return 'Size'; + + case 'GROUPFLD': + return 'Group'; + + case 'GROUP': + if ($mode == 'SELECT') $fld = '"Group"'; + return 'GroupFld'; + case 'SIZE': + if ($mode == 'SELECT') $fld = '"Size"'; + return 'SizeFld'; + } + return $fld; +} + +function ParseTable(&$table, &$pkey) +{ + $table = trim($table); + if (strlen($table) == 0) return false; + if (strpos($table, '#') !== false) { + $at = strpos($table, '#'); + $table = trim(substr($table,0,$at)); + if (strlen($table) == 0) return false; + } + + $tabarr = explode(',',$table); + if (sizeof($tabarr) == 1) { + $table = $tabarr[0]; + $pkey = ''; + echo "No primary key for $table **** ****
"; + } else { + $table = trim($tabarr[0]); + $pkey = trim($tabarr[1]); + if (strpos($pkey,' ') !== false) echo "Bad PKEY for $table $pkey
"; + } + + return true; +} + +global $TARR; + +function TableStats($rep, $table, $pkey) +{ +global $TARR; + + if (empty($TARR)) $TARR = array(); + $cnt = $rep->connSrc->GetOne("select count(*) from $table"); + if (isset($TARR[$table])) echo "

Table $table repeated twice

"; + $TARR[$table] = $cnt; + + if ($pkey) { + $ok = $rep->connSrc->SelectLimit("select $pkey from $table",1); + if (!$ok) echo "

$table: $pkey does not exist

"; + } else + echo "

$table: no primary key

"; +} + +function CreateTable($rep, $table) +{ +## CREATE TABLE + #$DB2->Execute("drop table $table"); + + $rep->execute = true; + $ok = $rep->CopyTableStruct($table); + if ($ok) echo "Table Created
\n"; + else { + echo "
Error: Cannot Create Table
\n"; + } + flush();@ob_flush(); +} + +function CopyData($rep, $table, $pkey) +{ + $dtable = $table; + + $rep->execute = true; + $rep->deleteFirst = true; + + $secs = time(); + $rows = $rep->ReplicateData($table,$dtable,array($pkey)); + $secs = time() - $secs; + if (!$rows || !$rows[0] || !$rows[1] || $rows[1] != $rows[2]+$rows[3]) { + echo "
Error: "; var_dump($rows); echo " (secs=$secs)
\n"; + } else + echo date('H:i:s'),': ',$rows[1]," record(s) copied, ",$rows[2]," inserted, ",$rows[3]," updated (secs=$secs)
\n"; + flush();@ob_flush(); +} + +function MergeDataJohnTest($rep, $table, $pkey) +{ + $rep->SwapDBs(); + + $dtable = $table; + $rep->oracleSequence = 'LGBSEQUENCE'; + +# $rep->MergeSrcSetup($table, array($pkey),'UpdatedOn','CopiedFlag'); + if (strpos($rep->connDest->databaseType,'mssql') !== false) { # oracle ==> mssql + $ignoreflds = array($pkey); + $ignoreflds[] = 'MSSQL_ID'; + $set = 'MSSQL_ID=nvl($INSERT_ID,MSSQL_ID)'; + $pkeyarr = array(array($pkey),false,array('MSSQL_ID'));# array('MSSQL_ID', 'ORA_ID')); + } else { # mssql ==> oracle + $ignoreflds = array($pkey); + $ignoreflds[] = 'ORA_ID'; + $set = ''; + #$set = 'ORA_ID=isnull($INSERT_ID,ORA_ID)'; + $pkeyarr = array(array($pkey),array('MSSQL_ID')); + } + $rep->execute = true; + #$rep->updateFirst = false; + $ok = $rep->Merge($table, $dtable, $pkeyarr, $ignoreflds, $set, 'UpdatedOn','CopiedFlag',array('Y','N','P','='), 'CopyDate'); + var_dump($ok); + + #$rep->connSrc->Execute("update JohnTest set name='Apple' where id=4"); +} + +$DB = ADONewConnection('odbtp'); +#$ok = $DB->Connect('localhost','root','','northwind'); +$ok = $DB->Connect('192.168.0.1','DRIVER={SQL Server};SERVER=(local);UID=sa;PWD=natsoft;DATABASE=OIR;','',''); +$DB->_bindInputArray = false; + +$DB2 = ADONewConnection('oci8'); +$ok2 = $DB2->Connect('192.168.0.2','tnb','natsoft','RAPTOR',''); + +if (!$ok || !$ok2) die("Failed connection DB=$ok DB2=$ok2
"); + +$tables = +" +JohnTest,id +"; + +# net* are ERMS, need last updated field from LGBnet +# tblRep* are tables insert or update from Juris, need last updated field also +# The rest are lookup tables, can copy all from LGBnet + +$tablesOrig = +" +SysVoltSubLevel,id +# Lookup table for Restoration Details screen +sysefi,ID # (not identity) +sysgenkva,ID #(not identity) +sysrestoredby,ID #(not identity) +# Sel* table added on 24 Oct +SELSGManufacturer,ID +SelABCCondSizeLV,ID +SelABCCondSizeMV,ID +SelArchingHornSize,ID +SelBallastSize,ID +SelBallastType,ID +SelBatteryType,ID #(not identity) +SelBreakerCapacity,ID +SelBreakerType,ID #(not identity) +SelCBreakerManuf,ID +SelCTRatio,ID #(not identity) +SelCableBrand,ID +SelCableSize,ID +SelCableSizeLV,ID # (not identity) +SelCapacitorSize,ID +SelCapacitorType,ID +SelColourCode,ID +SelCombineSealingChamberSize,ID +SelConductorBrand,ID +SelConductorSize4,ID +SelConductorSizeLV,ID +SelConductorSizeMV,ID +SelContactorSize,ID +SelContractor,ID +SelCoverType,ID +SelCraddleSize,ID +SelDeadEndClampBrand,ID +SelDeadEndClampSize,ID +SelDevTermination,ID +SelFPManuf,ID +SelFPillarRating,ID +SelFalseTrue,ID +SelFuseManuf,ID +SelFuseType,ID +SelIPCBrand,ID +SelIPCSize,ID +SelIgnitorSize,ID +SelIgnitorType,ID +SelInsulatorBrand,ID +SelJoint,ID +SelJointBrand,ID +SelJunctionBoxBrand,ID +SelLVBoardBrand,ID +SelLVBoardSize,ID +SelLVOHManuf,ID +SelLVVoltage,ID +SelLightningArresterBrand,ID +SelLightningShieldwireSize,ID +SelLineTapSize,ID +SelLocation,ID +SelMVVoltage,ID +SelMidSpanConnectorsSize,ID +SelMidSpanJointSize,ID +SelNERManuf,ID +SelNERType,ID +SelNLinkSize,ID +SelPVCCondSizeLV,ID +SelPoleBrand,ID +SelPoleConcreteSize,ID +SelPoleSize,ID +SelPoleSpunConcreteSize,ID +SelPoleSteelSize,ID +SelPoleType,ID +SelPoleWoodSize,ID +SelPorcelainFuseSize,ID +SelRatedFaultCurrentBreaker,ID +SelRatedVoltageSG,ID #(not identity) +SelRelayType,ID # (not identity) +SelResistanceValue,ID +SelSGEquipmentType,ID # (not identity) +SelSGInsulationType,ID # (not identity) +SelSGManufacturer,ID +SelStayInsulatorSize,ID +SelSuspensionClampBrand,ID +SelSuspensionClampSize,ID +SelTSwitchType,ID +SelTowerType,ID +SelTransformerCapacity,ID +SelTransformerManuf,ID +SelTransformerType,ID #(not identity) +SelTypeOfArchingHorn,ID +SelTypeOfCable,ID #(not identity) +SelTypeOfConductor,ID # (not identity) +SelTypeOfInsulationCB,ID # (not identity) +SelTypeOfMidSpanJoint,ID +SelTypeOfSTJoint,ID +SelTypeSTCable,ID +SelUGVoltage,ID # (not identity) +SelVoltageInOut,ID +SelWireSize,ID +SelWireType,ID +SelWonpieceBrand,ID +# +# Net* tables added on 24 Oct +NetArchingHorn,Idx +NetBatteryBank,Idx # identity, FunctLocation Pri +NetBiMetal,Idx +NetBoxFuse,Idx +NetCable,Idx # identity, FunctLocation Pri +NetCapacitorBank,Idx # identity, FunctLocation Pri +NetCircuitBreaker,Idx # identity, FunctLocation Pri +NetCombineSealingChamber,Idx +NetCommunication,Idx +NetCompInfras,Idx +NetControl,Idx +NetCraddle,Idx +NetDeadEndClamp,Idx +NetEarthing,Idx +NetFaultIndicator,Idx +NetFeederPillar,Idx # identity, FunctLocation Pri +NetGenCable,Idx # identity , FunctLocation Not Null +NetGenerator,Idx +NetGrid,Idx +NetHVOverhead,Idx #identity, FunctLocation Pri +NetHVUnderground,Idx #identity, FunctLocation Pri +NetIPC,Idx +NetInductorBank,Idx +NetInsulator,Idx +NetJoint,Idx +NetJunctionBox,Idx +NetLVDB,Idx #identity, FunctLocation Pri +NetLVOverhead,Idx +NetLVUnderground,Idx # identity, FunctLocation Not Null +NetLightningArrester,Idx +NetLineTap,Idx +NetMidSpanConnectors,Idx +NetMidSpanJoint,Idx +NetNER,Idx # identity , FunctLocation Pri +NetOilPump,Idx +NetOtherComponent,Idx +NetPole,Idx +NetRMU,Idx # identity, FunctLocation Pri +NetStreetLight,Idx +NetStrucSupp,Idx +NetSuspensionClamp,Idx +NetSwitchGear,Idx # identity, FunctLocation Pri +NetTermination,Idx +NetTransition,Idx +NetWonpiece,Idx +# +# comment1 +SelMVFuseType,ID +selFuseSize,ID +netRelay,Idx # identity, FunctLocation Pri +SysListVolt,ID +sysVoltLevel,ID_SVL +sysRestoration,ID_SRE +sysRepairMethod,ID_SRM # (not identity) + +sysInterruptionType,ID_SIN +netTransformer,Idx # identity, FunctLocation Pri +# +# +sysComponent,ID_SC +sysCodecibs #-- no idea, UpdatedOn(the only column is unique),Ermscode,Cibscode is unique but got null value +sysCodeno,id +sysProtection,ID_SP +sysEquipment,ID_SEQ +sysAddress #-- no idea, ID_SAD(might be auto gen No) +sysWeather,ID_SW +sysEnvironment,ID_SE +sysPhase,ID_SPH +sysFailureCause,ID_SFC +sysFailureMode,ID_SFM +SysSchOutageMode,ID_SSM +SysOutageType,ID_SOT +SysInstallation,ID_SI +SysInstallationCat,ID_SIC +SysInstallationType,ID_SIT +SysFaultCategory,ID_SF #(not identity) +SysResponsible,ID_SR +SysProtectionOperation,ID_SPO #(not identity) +netCodename,CodeNo #(not identity) +netSubstation,Idx #identity, FunctLocation Pri +netLvFeeder,Idx # identity, FunctLocation Pri +# +# +tblReport,ReportNo +tblRepRestoration,ID_RR +tblRepResdetail,ID_RRD +tblRepFailureMode,ID_RFM +tblRepFailureCause,ID_RFC +tblRepRepairMethod,ReportNo # (not identity) +tblInterruptionType,ID_TIN +tblProtType,ID_PT #--capital letter +tblRepProtection,ID_RP +tblRepComponent,ID_RC +tblRepWeather,ID_RW +tblRepEnvironment,ID_RE +tblRepSubstation,ID_RSS +tblInstallationType,ID_TIT +tblInstallationCat,ID_TIC +tblFailureCause,ID_TFC +tblFailureMode,ID_TFM +tblProtection,ID_TP +tblComponent,ID_TC +tblProtdetail,Id # (Id)--capital letter for I +tblInstallation,ID_TI +# +"; + + +$tables = explode("\n",$tables); + +$rep = new ADODB_Replicate($DB,$DB2); +$rep->fieldFilter = 'FieldFilter'; +$rep->selFilter = 'SELFILTER'; +$rep->indexFilter = 'IndexFilter'; + +if (1) { + $rep->debug = 1; + $DB->debug=1; + $DB2->debug=1; +} + +# $rep->SwapDBs(); + +$cnt = sizeof($tables); +foreach($tables as $k => $table) { + $pkey = ''; + if (!ParseTable($table, $pkey)) continue; + + ####################### + + $kcnt = $k+1; + echo "

($kcnt/$cnt) $table -- $pkey

\n"; + flush();@ob_flush(); + + CreateTable($rep,$table); + + + # COPY DATA + + + TableStats($rep, $table, $pkey); + + if ($table == 'JohnTest') MergeDataJohnTest($rep, $table, $pkey); + else CopyData($rep, $table, $pkey); + +} + + +if (!empty($TARR)) { + ksort($TARR); + adodb_pr($TARR); + asort($TARR); + adodb_pr($TARR); +} + +echo "
",date('H:i:s'),": Done"; diff --git a/e_lib/adodb5/rsfilter.inc.php b/vendor/adodb/adodb-php/rsfilter.inc.php similarity index 100% rename from e_lib/adodb5/rsfilter.inc.php rename to vendor/adodb/adodb-php/rsfilter.inc.php diff --git a/vendor/adodb/adodb-php/scripts/.gitignore b/vendor/adodb/adodb-php/scripts/.gitignore new file mode 100644 index 00000000..3e0e62b2 --- /dev/null +++ b/vendor/adodb/adodb-php/scripts/.gitignore @@ -0,0 +1,2 @@ +# Python byte code +*.pyc diff --git a/vendor/adodb/adodb-php/scripts/TARADO5.BAT b/vendor/adodb/adodb-php/scripts/TARADO5.BAT new file mode 100644 index 00000000..bf25ef99 --- /dev/null +++ b/vendor/adodb/adodb-php/scripts/TARADO5.BAT @@ -0,0 +1,49 @@ +@rem REQUIRES P:\INSTALLS\CMDUTILS + +echo Don't forget to strip LF's !!!!!!!!!!! +pause + + +set VER=518a + +d: +cd \inetpub\wwwroot\php + +@del /s /q zadodb\*.* +@mkdir zadodb + +@REM not for release -- make sure in VSS +attrib -r adodb5\drivers\adodb-text.inc.php +del adodb5\*.bak +del adodb5\drivers\*.bak +del adodb5\hs~*.* +del adodb5\drivers\hs~*.* +del adodb5\tests\hs~*.* +del adodb5\drivers\adodb-text.inc.php +del adodb5\.#* +del adodb5\replicate\replicate-steps.php +del adodb5\replicate\test*.php +del adodb5\adodb-lite.inc.php +attrib -r adodb5\*.php +del adodb5\cute_icons_for_site\*.png + +del tmp.tar +del adodb5*.tgz +del adodb5*.zip + +@mkdir adodb5\docs +move /y adodb5\*.htm adodb5\docs + +@rem CREATE TAR FILE +tar -f adodb%VER%.tar -c adodb5/*.* adodb5/perf/*.* adodb5/session/*.* adodb5/pear/*.txt adodb5/pear/Auth/Container/ADOdb.php adodb5/session/old/*.* adodb5/drivers/*.* adodb5/lang/*.* adodb5/tests/*.* adodb5/cute_icons_for_site/*.* adodb5/datadict/*.* adodb5/contrib/*.* adodb5/xsl/*.* adodb5/docs/*.* + +@rem CREATE ZIP FILE +cd zadodb +tar -xf ..\adodb%VER%.TAR +zip -r ..\adodb%VER%.zip adodb5 +cd .. + +@rem CREATE TGZ FILE, THE RENAME CHANGES UPPERCASE TO LOWERCASE +gzip -v ADODB%VER%.tar -S .tgz -9 +rename ADODB%VER%.tar.TGZ adodb%VER%.tgz + diff --git a/vendor/adodb/adodb-php/scripts/buildrelease.py b/vendor/adodb/adodb-php/scripts/buildrelease.py new file mode 100644 index 00000000..0b37b97b --- /dev/null +++ b/vendor/adodb/adodb-php/scripts/buildrelease.py @@ -0,0 +1,270 @@ +#!/usr/bin/python -u +''' + ADOdb release build script + + - Create release tag if it does not exist + - Copy release files to target directory + - Generate zip/tar balls + - +''' + +import errno +import getopt +import re +import os +from os import path +import shutil +import subprocess +import sys +import tempfile + +import updateversion + + +# ADOdb Repository reference +origin_repo = "https://github.com/ADOdb/ADOdb.git" +release_branch = "master" +release_prefix = "adodb" + +# Directories and files to exclude from release tarballs +exclude_list = (".git*", + "replicate", + "scripts", + "tests", + # There are no png files in there... + # "cute_icons_for_site/*.png", + "hs~*.*", + "adodb-text.inc.php", + # This file does not exist in current repo + # 'adodb-lite.inc.php' + ) + +# Command-line options +options = "hb:dfk" +long_options = ["help", "branch", "debug", "fresh", "keep"] + +# Global flags +debug_mode = False +fresh_clone = False +cleanup = True + + +def usage(): + print '''Usage: %s [options] version release_path + + Parameters: + version ADOdb version to bundle (e.g. v5.19) + release_path Where to save the release tarballs + + Options: + -h | --help Show this usage message + + -b | --branch Use specified branch (defaults to '%s' for '.0' + releases, or 'hotfix/' for patches) + -d | --debug Debug mode (ignores upstream: no fetch, allows + build even if local branch is not in sync) + -f | --fresh Create a fresh clone of the repository + -k | --keep Keep build directories after completion + (useful for debugging) +''' % ( + path.basename(__file__), + release_branch + ) +#end usage() + + +def set_version_and_tag(version): + ''' + ''' + global release_branch, debug_mode, fresh_clone, cleanup + + # Delete existing tag to force creation in debug mode + if debug_mode: + try: + updateversion.tag_delete(version) + except: + pass + + # Checkout release branch + subprocess.call("git checkout %s" % release_branch, shell=True) + + if not debug_mode: + # Make sure we're up-to-date, ignore untracked files + ret = subprocess.check_output( + "git status --branch --porcelain --untracked-files=no", + shell=True + ) + if not re.search(release_branch + "$", ret): + print "\nERROR: branch must be aligned with upstream" + sys.exit(4) + + # Update the code, create commit and tag + updateversion.version_set(version) + + # Make sure we don't delete the modified repo + if fresh_clone: + cleanup = False + + +def main(): + global release_branch, debug_mode, fresh_clone, cleanup + + # Get command-line options + try: + opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options) + except getopt.GetoptError, err: + print str(err) + usage() + sys.exit(2) + + if len(args) < 2: + usage() + print "ERROR: please specify the version and release_path" + sys.exit(1) + + for opt, val in opts: + if opt in ("-h", "--help"): + usage() + sys.exit(0) + + elif opt in ("-b", "--branch"): + release_branch = val + + elif opt in ("-d", "--debug"): + debug_mode = True + + elif opt in ("-f", "--fresh"): + fresh_clone = True + + elif opt in ("-k", "--keep"): + cleanup = False + + # Mandatory parameters + version = updateversion.version_check(args[0]) + release_path = args[1] + + # Default release branch + if updateversion.version_is_patch(version): + release_branch = 'hotfix/' + version + + # ------------------------------------------------------------------------- + # Start the build + # + global release_prefix + + print "Building ADOdb release %s into '%s'\n" % ( + version, + release_path + ) + + if debug_mode: + print "DEBUG MODE: ignoring upstream repository status" + + if fresh_clone: + # Create a new repo clone + print "Cloning a new repository" + repo_path = tempfile.mkdtemp(prefix=release_prefix + "-", + suffix=".git") + subprocess.call( + "git clone %s %s" % (origin_repo, repo_path), + shell=True + ) + os.chdir(repo_path) + else: + repo_path = subprocess.check_output('git root', shell=True).rstrip() + os.chdir(repo_path) + + # Check for any uncommitted changes + try: + subprocess.check_output( + "git diff --exit-code && " + "git diff --cached --exit-code", + shell=True + ) + except: + print "ERROR: there are uncommitted changes in the repository" + sys.exit(3) + + # Update the repository + if not debug_mode: + print "Updating repository in '%s'" % os.getcwd() + try: + subprocess.check_output("git fetch", shell=True) + except: + print "ERROR: unable to fetch\n" + sys.exit(3) + + # Check existence of Tag for version in repo, create if not found + try: + updateversion.tag_check(version) + if debug_mode: + set_version_and_tag(version) + except: + set_version_and_tag(version) + + # Copy files to release dir + release_files = release_prefix + version.split(".")[0] + release_tmp_dir = path.join(release_path, release_files) + print "Copying release files to '%s'" % release_tmp_dir + retry = True + while True: + try: + shutil.copytree( + repo_path, + release_tmp_dir, + ignore=shutil.ignore_patterns(*exclude_list) + ) + break + except OSError, err: + # First try and file exists, try to delete dir + if retry and err.errno == errno.EEXIST: + print "WARNING: Directory '%s' exists, delete it and retry" % ( + release_tmp_dir + ) + shutil.rmtree(release_tmp_dir) + retry = False + continue + else: + # We already tried to delete or some other error occured + raise + + # Create tarballs + print "Creating release tarballs..." + release_name = release_prefix + '-' + version + print release_prefix, version, release_name + + os.chdir(release_path) + print "- tar" + subprocess.call( + "tar -czf %s.tar.gz %s" % (release_name, release_files), + shell=True + ) + print "- zip" + subprocess.call( + "zip -rq %s.zip %s" % (release_name, release_files), + shell=True + ) + + if cleanup: + print "Deleting working directories" + shutil.rmtree(release_tmp_dir) + if fresh_clone: + shutil.rmtree(repo_path) + else: + print "\nThe following working directories were kept:" + if fresh_clone: + print "- '%s' (repo clone)" % repo_path + print "- '%s' (release temp dir)" % release_tmp_dir + print "Delete them manually when they are no longer needed." + + # Done + print "\nADOdb release %s build complete, files saved in '%s'." % ( + version, + release_path + ) + print "Don't forget to generate a README file with the changelog" + +#end main() + +if __name__ == "__main__": + main() diff --git a/vendor/adodb/adodb-php/scripts/updateversion.py b/vendor/adodb/adodb-php/scripts/updateversion.py new file mode 100644 index 00000000..0c39fd53 --- /dev/null +++ b/vendor/adodb/adodb-php/scripts/updateversion.py @@ -0,0 +1,399 @@ +#!/usr/bin/python -u +''' + ADOdb version update script + + Updates the version number, and release date in all php and html files +''' + +from datetime import date +import getopt +import os +from os import path +import re +import subprocess +import sys + + +# ADOdb version validation regex +# These are used by sed - they are not PCRE ! +_version_dev = "dev" +_version_regex = "[Vv]?([0-9]\.[0-9]+)(\.([0-9]+))?(-?%s)?" % _version_dev +_release_date_regex = "[0-9?]+-.*-[0-9]+" +_changelog_file = "docs/changelog.md" + +_tag_prefix = "v" + + +# Command-line options +options = "hct" +long_options = ["help", "commit", "tag"] + + +def usage(): + print '''Usage: %s version + + Parameters: + version ADOdb version, format: [v]X.YY[a-z|dev] + + Options: + -c | --commit Automatically commit the changes + -t | --tag Create a tag for the new release + -h | --help Show this usage message +''' % ( + path.basename(__file__) + ) +#end usage() + + +def version_is_dev(version): + ''' Returns true if version is a development release + ''' + return version.endswith(_version_dev) + + +def version_is_patch(version): + ''' Returns true if version is a patch release (i.e. X.Y.Z with Z > 0) + ''' + return not version.endswith('.0') + + +def version_parse(version): + ''' Breakdown the version into groups (Z and -dev are optional) + 1:(X.Y), 2:(.Z), 3:(Z), 4:(-dev) + ''' + return re.match(r'^%s$' % _version_regex, version) + + +def version_check(version): + ''' Checks that the given version is valid, exits with error if not. + Returns the SemVer-normalized version without the "v" prefix + - add '.0' if missing patch bit + - add '-' before dev release suffix if needed + ''' + vparse = version_parse(version) + if not vparse: + usage() + print "ERROR: invalid version ! \n" + sys.exit(1) + + vnorm = vparse.group(1) + + # Add .patch version component + if vparse.group(2): + vnorm += vparse.group(2) + else: + # None was specified, assume a .0 release + vnorm += '.0' + + # Normalize version number + if version_is_dev(version): + vnorm += '-' + _version_dev + + return vnorm + + +def get_release_date(version): + ''' Returns the release date in DD-MMM-YYYY format + For development releases, DD-MMM will be ??-??? + ''' + # Development release + if version_is_dev(version): + date_format = "??-???-%Y" + else: + date_format = "%d-%b-%Y" + + # Define release date + return date.today().strftime(date_format) + + +def sed_script(version): + ''' Builds sed script to update version information in source files + ''' + + # Version number and release date + script = r"s/{}\s+(-?)\s+{}/v{} \5 {}/".format( + _version_regex, + _release_date_regex, + version, + get_release_date(version) + ) + + return script + + +def sed_filelist(): + ''' Build list of files to update + ''' + dirlist = [] + for root, dirs, files in os.walk(".", topdown=True): + # Filter files by extensions + files = [ + f for f in files + if re.search(r'\.(php|html?)$', f, re.IGNORECASE) + ] + for fname in files: + dirlist.append(path.join(root, fname)) + + return dirlist + + +def tag_name(version): + return _tag_prefix + version + + +def tag_check(version): + ''' Checks if the tag for the specified version exists in the repository + by attempting to check it out + Throws exception if not + ''' + subprocess.check_call( + "git checkout --quiet " + tag_name(version), + stderr=subprocess.PIPE, + shell=True) + print "Tag '%s' already exists" % tag_name(version) + + +def tag_delete(version): + ''' Deletes the specified tag + ''' + subprocess.check_call( + "git tag --delete " + tag_name(version), + stderr=subprocess.PIPE, + shell=True) + + +def tag_create(version): + ''' Creates the tag for the specified version + Returns True if tag created + ''' + print "Creating release tag '%s'" % tag_name(version) + result = subprocess.call( + "git tag --sign --message '%s' %s" % ( + "ADOdb version %s released %s" % ( + version, + get_release_date(version) + ), + tag_name(version) + ), + shell=True + ) + return result == 0 + + +def section_exists(filename, version, print_message=True): + ''' Checks given file for existing section with specified version + ''' + script = True + for i, line in enumerate(open(filename)): + if re.search(r'^## ' + version, line): + if print_message: + print " Existing section for v%s found," % version, + return True + return False + + +def version_get_previous(version): + ''' Returns the previous version number + Don't decrease major versions (raises exception) + ''' + vprev = version.split('.') + item = len(vprev) - 1 + + while item > 0: + val = int(vprev[item]) + if val > 0: + vprev[item] = str(val - 1) + break + else: + item -= 1 + + if item == 0: + raise ValueError('Refusing to decrease major version number') + + return '.'.join(vprev) + + +def update_changelog(version): + ''' Updates the release date in the Change Log + ''' + print "Updating Changelog" + + vparse = version_parse(version) + + # Version number without '-dev' suffix + version_release = vparse.group(1) + vparse.group(2) + version_previous = version_get_previous(version_release) + + if not section_exists(_changelog_file, version_previous, False): + raise ValueError( + "ERROR: previous version %s does not exist in changelog" % + version_previous + ) + + # Check if version already exists in changelog + version_exists = section_exists(_changelog_file, version_release) + if (not version_exists + and not version_is_patch(version) + and not version_is_dev(version)): + version += '-' + _version_dev + + release_date = get_release_date(version) + + # Development release + # Insert a new section for next release before the most recent one + if version_is_dev(version): + # Check changelog file for existing section + if version_exists: + print "nothing to do" + return + + # No existing section found, insert new one + if version_is_patch(version_release): + print " Inserting new section for hotfix release v%s" % version + else: + print " Inserting new section for v%s" % version_release + # Adjust previous version number (remove patch component) + version_previous = version_parse(version_previous).group(1) + script = "1,/^## {0}/s/^## {0}.*$/## {1} - {2}\\n\\n\\0/".format( + version_previous, + version_release, + release_date + ) + + # Stable release (X.Y.0) + # Replace the 1st occurence of markdown level 2 header matching version + # and release date patterns + elif not version_is_patch(version): + print " Updating release date for v%s" % version + script = r"s/^(## ){0}(\.0)? - {1}.*$/\1{2} - {3}/".format( + vparse.group(1), + _release_date_regex, + version, + release_date + ) + + # Hotfix release (X.Y.[0-9]) + # Insert a new section for the hotfix release before the most recent + # section for version X.Y and display a warning message + else: + if version_exists: + print 'updating release date' + script = "s/^## {0}.*$/## {1} - {2}/".format( + version.replace('.', '\.'), + version, + release_date + ) + else: + print " Inserting new section for hotfix release v%s" % version + script = "1,/^## {0}/s/^## {0}.*$/## {1} - {2}\\n\\n\\0/".format( + version_previous, + version, + release_date + ) + + print " WARNING: review '%s' to ensure added section is correct" % ( + _changelog_file + ) + + subprocess.call( + "sed -r -i '%s' %s " % ( + script, + _changelog_file + ), + shell=True + ) +#end update_changelog + + +def version_set(version, do_commit=True, do_tag=True): + ''' Bump version number and set release date in source files + ''' + print "Preparing version bump commit" + + update_changelog(version) + + print "Updating version and date in source files" + subprocess.call( + "sed -r -i '%s' %s " % ( + sed_script(version), + " ".join(sed_filelist()) + ), + shell=True + ) + print "Version set to %s" % version + + if do_commit: + # Commit changes + print "Committing" + commit_ok = subprocess.call( + "git commit --all --message '%s'" % ( + "Bump version to %s" % version + ), + shell=True + ) + + if do_tag: + tag_ok = tag_create(version) + else: + tag_ok = False + + if commit_ok == 0: + print ''' +NOTE: you should carefully review the new commit, making sure updates +to the files are correct and no additional changes are required. +If everything is fine, then the commit can be pushed upstream; +otherwise: + - Make the required corrections + - Amend the commit ('git commit --all --amend' ) or create a new one''' + + if tag_ok: + print ''' - Drop the tag ('git tag --delete %s') + - run this script again +''' % ( + tag_name(version) + ) + + else: + print "Note: changes have been staged but not committed." +#end version_set() + + +def main(): + # Get command-line options + try: + opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options) + except getopt.GetoptError, err: + print str(err) + usage() + sys.exit(2) + + if len(args) < 1: + usage() + print "ERROR: please specify the version" + sys.exit(1) + + do_commit = False + do_tag = False + + for opt, val in opts: + if opt in ("-h", "--help"): + usage() + sys.exit(0) + + elif opt in ("-c", "--commit"): + do_commit = True + + elif opt in ("-t", "--tag"): + do_tag = True + + # Mandatory parameters + version = version_check(args[0]) + + # Let's do it + os.chdir(subprocess.check_output('git root', shell=True).rstrip()) + version_set(version, do_commit, do_tag) +#end main() + + +if __name__ == "__main__": + main() diff --git a/vendor/adodb/adodb-php/scripts/uploadrelease.py b/vendor/adodb/adodb-php/scripts/uploadrelease.py new file mode 100644 index 00000000..5b295cbb --- /dev/null +++ b/vendor/adodb/adodb-php/scripts/uploadrelease.py @@ -0,0 +1,172 @@ +#!/usr/bin/python -u +''' + ADOdb release upload script +''' + +from distutils.version import LooseVersion +import getopt +import glob +import os +from os import path +import re +import subprocess +import sys + + +# Directories and files to exclude from release tarballs +sf_files = "frs.sourceforge.net:/home/frs/project/adodb/" +rsync_cmd = "rsync -vP --rsh ssh {opt} {src} {usr}@{dst}" + +# Command-line options +options = "hn" +long_options = ["help", "dry-run"] + + +def usage(): + print '''Usage: %s [options] username [release_path] + + This script will upload the files in the given directory (or the + current one if unspecified) to Sourceforge. + + Parameters: + username Sourceforge user account + release_path Location of the release files to upload + (see buildrelease.py) + + Options: + -h | --help Show this usage message + -n | --dry-run Do not upload the files +''' % ( + path.basename(__file__) + ) +#end usage() + + +def call_rsync(usr, opt, src, dst): + ''' Calls rsync to upload files with given parameters + usr = ssh username + opt = options + src = source directory + dst = target directory + ''' + global dry_run + + command = rsync_cmd.format(usr=usr, opt=opt, src=src, dst=dst) + + if dry_run: + print command + else: + subprocess.call(command, shell=True) + + +def get_release_version(): + ''' Get the version number from the zip file to upload + ''' + try: + zipfile = glob.glob('adodb-*.zip')[0] + except IndexError: + print "ERROR: release zip file not found in '%s'" % release_path + sys.exit(1) + + try: + version = re.search( + "^adodb-([\d]+\.[\d]+\.[\d]+)\.zip$", + zipfile + ).group(1) + except AttributeError: + print "ERROR: unable to extract version number from '%s'" % zipfile + print " Only 3 groups of digits separated by periods are allowed" + sys.exit(1) + + return version + + +def sourceforge_target_dir(version): + ''' Returns the sourceforge target directory + Base directory as defined in sf_files global variable, plus + - if version >= 5.21: adodb-X.Y + - for older versions: adodb-XYZ-for-php5 + ''' + # Keep only X.Y (discard patch number) + short_version = version.rsplit('.', 1)[0] + + directory = 'adodb-php5-only/' + if LooseVersion(version) >= LooseVersion('5.21'): + directory += "adodb-" + short_version + else: + directory += "adodb-{}-for-php5".format(short_version.replace('.', '')) + + return directory + + +def process_command_line(): + ''' Retrieve command-line options and set global variables accordingly + ''' + global upload_files, upload_doc, dry_run, username, release_path + + # Get command-line options + try: + opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options) + except getopt.GetoptError, err: + print str(err) + usage() + sys.exit(2) + + if len(args) < 1: + usage() + print "ERROR: please specify the Sourceforge user and release_path" + sys.exit(1) + + # Default values for flags + dry_run = False + + for opt, val in opts: + if opt in ("-h", "--help"): + usage() + sys.exit(0) + + elif opt in ("-n", "--dry-run"): + dry_run = True + + # Mandatory parameters + username = args[0] + + # Change to release directory, current if not specified + try: + release_path = args[1] + os.chdir(release_path) + except IndexError: + release_path = os.getcwd() + + +def upload_release_files(): + ''' Upload release files from source directory to SourceForge + ''' + version = get_release_version() + target = sf_files + sourceforge_target_dir(version) + + print + print "Uploading release files..." + print " Source:", release_path + print " Target: " + target + print + call_rsync( + username, + "", + path.join(release_path, "*"), + target + ) + + +def main(): + process_command_line() + + # Start upload process + print "ADOdb release upload script" + + upload_release_files() + +#end main() + +if __name__ == "__main__": + main() diff --git a/e_lib/adodb5/server.php b/vendor/adodb/adodb-php/server.php similarity index 100% rename from e_lib/adodb5/server.php rename to vendor/adodb/adodb-php/server.php diff --git a/e_lib/adodb5/session/adodb-compress-bzip2.php b/vendor/adodb/adodb-php/session/adodb-compress-bzip2.php similarity index 100% rename from e_lib/adodb5/session/adodb-compress-bzip2.php rename to vendor/adodb/adodb-php/session/adodb-compress-bzip2.php diff --git a/e_lib/adodb5/session/adodb-compress-gzip.php b/vendor/adodb/adodb-php/session/adodb-compress-gzip.php similarity index 100% rename from e_lib/adodb5/session/adodb-compress-gzip.php rename to vendor/adodb/adodb-php/session/adodb-compress-gzip.php diff --git a/e_lib/adodb5/session/adodb-cryptsession.php b/vendor/adodb/adodb-php/session/adodb-cryptsession.php similarity index 100% rename from e_lib/adodb5/session/adodb-cryptsession.php rename to vendor/adodb/adodb-php/session/adodb-cryptsession.php diff --git a/e_lib/adodb5/session/adodb-cryptsession2.php b/vendor/adodb/adodb-php/session/adodb-cryptsession2.php similarity index 100% rename from e_lib/adodb5/session/adodb-cryptsession2.php rename to vendor/adodb/adodb-php/session/adodb-cryptsession2.php diff --git a/e_lib/adodb5/session/adodb-encrypt-mcrypt.php b/vendor/adodb/adodb-php/session/adodb-encrypt-mcrypt.php similarity index 100% rename from e_lib/adodb5/session/adodb-encrypt-mcrypt.php rename to vendor/adodb/adodb-php/session/adodb-encrypt-mcrypt.php diff --git a/e_lib/adodb5/session/adodb-encrypt-md5.php b/vendor/adodb/adodb-php/session/adodb-encrypt-md5.php similarity index 100% rename from e_lib/adodb5/session/adodb-encrypt-md5.php rename to vendor/adodb/adodb-php/session/adodb-encrypt-md5.php diff --git a/e_lib/adodb5/session/adodb-encrypt-secret.php b/vendor/adodb/adodb-php/session/adodb-encrypt-secret.php similarity index 100% rename from e_lib/adodb5/session/adodb-encrypt-secret.php rename to vendor/adodb/adodb-php/session/adodb-encrypt-secret.php diff --git a/e_lib/adodb5/session/adodb-encrypt-sha1.php b/vendor/adodb/adodb-php/session/adodb-encrypt-sha1.php similarity index 100% rename from e_lib/adodb5/session/adodb-encrypt-sha1.php rename to vendor/adodb/adodb-php/session/adodb-encrypt-sha1.php diff --git a/e_lib/adodb5/session/adodb-sess.txt b/vendor/adodb/adodb-php/session/adodb-sess.txt similarity index 100% rename from e_lib/adodb5/session/adodb-sess.txt rename to vendor/adodb/adodb-php/session/adodb-sess.txt diff --git a/e_lib/adodb5/session/adodb-session-clob.php b/vendor/adodb/adodb-php/session/adodb-session-clob.php similarity index 100% rename from e_lib/adodb5/session/adodb-session-clob.php rename to vendor/adodb/adodb-php/session/adodb-session-clob.php diff --git a/e_lib/adodb5/session/adodb-session-clob2.php b/vendor/adodb/adodb-php/session/adodb-session-clob2.php similarity index 100% rename from e_lib/adodb5/session/adodb-session-clob2.php rename to vendor/adodb/adodb-php/session/adodb-session-clob2.php diff --git a/e_lib/adodb5/session/adodb-session.php b/vendor/adodb/adodb-php/session/adodb-session.php similarity index 100% rename from e_lib/adodb5/session/adodb-session.php rename to vendor/adodb/adodb-php/session/adodb-session.php diff --git a/e_lib/adodb5/session/adodb-session2.php b/vendor/adodb/adodb-php/session/adodb-session2.php similarity index 100% rename from e_lib/adodb5/session/adodb-session2.php rename to vendor/adodb/adodb-php/session/adodb-session2.php diff --git a/e_lib/adodb5/session/adodb-sessions.mysql.sql b/vendor/adodb/adodb-php/session/adodb-sessions.mysql.sql similarity index 100% rename from e_lib/adodb5/session/adodb-sessions.mysql.sql rename to vendor/adodb/adodb-php/session/adodb-sessions.mysql.sql diff --git a/e_lib/adodb5/session/adodb-sessions.oracle.clob.sql b/vendor/adodb/adodb-php/session/adodb-sessions.oracle.clob.sql similarity index 100% rename from e_lib/adodb5/session/adodb-sessions.oracle.clob.sql rename to vendor/adodb/adodb-php/session/adodb-sessions.oracle.clob.sql diff --git a/e_lib/adodb5/session/adodb-sessions.oracle.sql b/vendor/adodb/adodb-php/session/adodb-sessions.oracle.sql similarity index 100% rename from e_lib/adodb5/session/adodb-sessions.oracle.sql rename to vendor/adodb/adodb-php/session/adodb-sessions.oracle.sql diff --git a/e_lib/adodb5/session/crypt.inc.php b/vendor/adodb/adodb-php/session/crypt.inc.php similarity index 100% rename from e_lib/adodb5/session/crypt.inc.php rename to vendor/adodb/adodb-php/session/crypt.inc.php diff --git a/e_lib/adodb5/session/old/adodb-cryptsession.php b/vendor/adodb/adodb-php/session/old/adodb-cryptsession.php similarity index 100% rename from e_lib/adodb5/session/old/adodb-cryptsession.php rename to vendor/adodb/adodb-php/session/old/adodb-cryptsession.php diff --git a/e_lib/adodb5/session/old/adodb-session-clob.php b/vendor/adodb/adodb-php/session/old/adodb-session-clob.php similarity index 100% rename from e_lib/adodb5/session/old/adodb-session-clob.php rename to vendor/adodb/adodb-php/session/old/adodb-session-clob.php diff --git a/e_lib/adodb5/session/old/adodb-session.php b/vendor/adodb/adodb-php/session/old/adodb-session.php similarity index 100% rename from e_lib/adodb5/session/old/adodb-session.php rename to vendor/adodb/adodb-php/session/old/adodb-session.php diff --git a/e_lib/adodb5/session/old/crypt.inc.php b/vendor/adodb/adodb-php/session/old/crypt.inc.php similarity index 100% rename from e_lib/adodb5/session/old/crypt.inc.php rename to vendor/adodb/adodb-php/session/old/crypt.inc.php diff --git a/e_lib/adodb5/session/session_schema.xml b/vendor/adodb/adodb-php/session/session_schema.xml similarity index 100% rename from e_lib/adodb5/session/session_schema.xml rename to vendor/adodb/adodb-php/session/session_schema.xml diff --git a/e_lib/adodb5/session/session_schema2.xml b/vendor/adodb/adodb-php/session/session_schema2.xml similarity index 100% rename from e_lib/adodb5/session/session_schema2.xml rename to vendor/adodb/adodb-php/session/session_schema2.xml diff --git a/vendor/adodb/adodb-php/tests/benchmark.php b/vendor/adodb/adodb-php/tests/benchmark.php new file mode 100644 index 00000000..5ba5e8bc --- /dev/null +++ b/vendor/adodb/adodb-php/tests/benchmark.php @@ -0,0 +1,86 @@ + + + + + ADODB Benchmarks + + + +ADODB Version: $ADODB_version Host: $db->host   Database: $db->database"; + + // perform query once to cache results so we are only testing throughput + $rs = $db->Execute($sql); + if (!$rs){ + print "Error in recordset

"; + 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

",$total,$max, sizeof($arr)); + flush(); + + + //$db->Close(); +} +include("testdatabases.inc.php"); + +?> + + + + diff --git a/vendor/adodb/adodb-php/tests/client.php b/vendor/adodb/adodb-php/tests/client.php new file mode 100644 index 00000000..5b30065a --- /dev/null +++ b/vendor/adodb/adodb-php/tests/client.php @@ -0,0 +1,199 @@ + + +'; + var_dump(parse_url('odbc_mssql://userserver/')); + die(); + +include('../adodb.inc.php'); +include('../tohtml.inc.php'); + + function send2server($url,$sql) + { + $url .= '?sql='.urlencode($sql); + print "

$url

"; + $rs = csv2rs($url,$err); + if ($err) print $err; + return $rs; + } + + function print_pre($s) + { + print "
";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 Tests

"; + print "

Test 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 00000000..31ca5969 --- /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 00000000..59471620 --- /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 "

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, "
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 00000000..f5898fcd --- /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 "

Affected Rows after delete=".$db->Affected_Rows()."

"; diff --git a/vendor/adodb/adodb-php/tests/test-active-relations.php b/vendor/adodb/adodb-php/tests/test-active-relations.php new file mode 100644 index 00000000..7a98d479 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test-active-relations.php @@ -0,0 +1,85 @@ +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; + "); + + + $db->Execute("insert into children (person_id,name_first,name_last) values (1,'Jill','Lim')"); + $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')"); + + ADODB_Active_Record::TableHasMany('persons', 'children','person_id'); + class person extends ADOdb_Active_Record{} + + $person = new person(); +# $person->HasMany('children','person_id'); ## this is affects all other instances of Person + + $person->name_first = 'John'; + $person->name_last = 'Lim'; + $person->favorite_color = 'lavender'; + $person->save(); // this save will perform an INSERT successfully + + $person2 = new person(); + $person2->Load('id=1'); + + $c = $person2->children; + 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{}; + 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 00000000..0f28f728 --- /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 00000000..9c7422aa --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test-datadict.php @@ -0,0 +1,251 @@ +$dbType

"; + $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 "

";
+	//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 00000000..62465bef --- /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->HealthCheck(); + echo($perf->SuspiciousSQL()); + echo($perf->ExpensiveSQL()); + echo($perf->InvalidSQL()); + echo $perf->Tables(); + + echo "

";
+		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 00000000..3add99e6
--- /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 "

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 "

Testing PREPARE/EXECUTE PLAN

"; + + +$db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database +$t = getmicrotime(); +doloop(); +echo '

',$MAX,' times, with plan=',getmicrotime() - $t,'

'; + + +$db->_bindInputArray = false; +$t = getmicrotime(); +doloop(); +echo '

',$MAX,' times, no plan=',getmicrotime() - $t,'

'; + + + +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 "INSERTED: ", $val; +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 00000000..a8f1ffe5 --- /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 ?Prepare("select * from adoxyz where ?ErrorMsg(),"\n"; +$rs = $db->Execute($stmt,array(10,20)); + +echo "
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 "

empty ";var_dump($v); +} + + +if ($i != $cnt) die("actual cnt is $i, cnt should be $cnt\n"); +else echo "Count $i is correct
"; + +$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,"

"; + +echo "

Active Record

"; + + include_once("../adodb-active-record.inc.php"); + ADOdb_Active_Record::SetDatabaseAdapter($db); + +try { + class City extends ADOdb_Active_Record{}; + $a = new City(); + +} catch(exception $e){ + echo $e->getMessage(); +} + +try { + + $a = new City(); + + echo "

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 00000000..c56cfec8 --- /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 00000000..50e74ad4 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test.php @@ -0,0 +1,1781 @@ +$msg

"; + flush(); +} + +function CheckWS($conn) +{ +global $ADODB_EXTENSION; + + include_once('../session/adodb-session.php'); + if (defined('CHECKWSFAIL')){ echo " TESTING $conn ";flush();} + $saved = $ADODB_EXTENSION; + $db = ADONewConnection($conn); + $ADODB_EXTENSION = $saved; + if (headers_sent()) { + print "

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); + +?>
+

+
 
+

+Execute('select lastname,firstname,lastname,id from ADOXYZ'); + $arr = $rs->GetAssoc(); + echo "
";print_r($arr);
+	die();*/
+
+	if (!$db) die("testdb: database not inited");
+	GLOBAL $EXECS, $CACHED;
+
+	$EXECS = 0;
+	$CACHED = 0;
+	//$db->Execute("drop table adodb_logsql");
+	if ((rand()%3) == 0) @$db->Execute("delete from adodb_logsql");
+	$db->debug=1;
+
+	$db->fnExecute = 'CountExecs';
+	$db->fnCacheExecute = 'CountCachedExecs';
+
+	if (empty($_GET['nolog'])) {
+		echo "

SQL Logging enabled

"; + $db->LogSQL();/* + $sql = +"SELECT t1.sid, t1.sid, t1.title, t1.hometext, t1.notes, t1.aid, t1.informant, +t2.url, t2.email, t1.catid, t3.title, t1.topic, t4.topicname, t4.topicimage, +t4.topictext, t1.score, t1.ratings, t1.counter, t1.comments, t1.acomm +FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_topics` `t4` + WHERE ((t2.aid=t1.aid) AND (t3.catid=t1.catid) AND (t4.topicid=t1.topic) + AND ((t1.alanguage='german') OR (t1.alanguage='')) AND (t1.ihome='0')) + ORDER BY t1.time DESC"; + $db->SelectLimit($sql); + echo $db->ErrorMsg();*/ + } + $ADODB_CACHE_DIR = dirname(TempNam('/tmp','testadodb')); + $db->debug = false; + //print $db->UnixTimeStamp('2003-7-22 23:00:00'); + + $phpv = phpversion(); + if (defined('ADODB_EXTENSION')) $ext = '   Extension '.ADODB_EXTENSION.' installed'; + else $ext = ''; + print "

ADODB Version: $ADODB_vers"; + print "

Host: $db->host"; + print "
Database: $db->database"; + print "
PHP: $phpv $ext

"; + + flush(); + + print "Current timezone: " . date_default_timezone_get() . "

"; + + $arr = $db->ServerInfo(); + print_r($arr); + echo E_ALL,' ',E_STRICT, "
"; + $e = error_reporting(E_ALL | E_STRICT); + echo error_reporting(),'

'; + flush(); + #$db->debug=1; + $tt = $db->Time(); + if ($tt == 0) echo '
$db->Time failed'; + else echo "
db->Time: ".date('d-m-Y H:i:s',$tt); + echo '
'; + + echo "Date=",$db->UserDate('2002-04-07'),'
'; + print "date1 (1969-02-20) = ".$db->DBDate('1969-2-20'); + print "
date1 (1999-02-20) = ".$db->DBDate('1999-2-20'); + print "
date1.1 1999 injection attack= ".$db->DBDate("'1999', ' injection attack '"); + print "
date2 (1970-1-2) = ".$db->DBDate(24*3600)."

"; + print "ts1 (1999-02-20 13:40:50) = ".$db->DBTimeStamp('1999-2-20 1:40:50 pm'); + print "
ts1.1 (1999-02-20 13:40:00) = ".$db->DBTimeStamp('1999-2-20 13:40'); + print "
ts2 (1999-02-20) = ".$db->DBTimeStamp('1999-2-20'); + print "
ts2 (1999-02-20) = ".$db->DBTimeStamp("'1999-2-20', 'injection attack'"); + print "
ts3 (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600); + print "
Fractional TS (1999-2-20 13:40:50.91): ".$db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1')); + $dd = $db->UnixDate('1999-02-20'); + print "
unixdate 1999-02-20 = ".date('Y-m-d',$dd)."

"; + print "
ts4 =".($db->UnixTimeStamp("19700101000101")+8*3600); + print "
ts5 =".$db->DBTimeStamp($db->UnixTimeStamp("20040110092123")); + print "
ts6 =".$db->UserTimeStamp("20040110092123"); + print "
ts7 =".$db->DBTimeStamp("20040110092123"); + flush(); + // mssql too slow in failing bad connection + if (false && $db->databaseType != 'mssql') { + print "

Testing bad connection. Ignore following error msgs:
"; + $db2 = ADONewConnection(); + $rez = $db2->Connect("bad connection"); + $err = $db2->ErrorMsg(); + print "Error='$err'

"; + if ($rez) print "Cannot check if connection failed. The Connect() function returned true.

"; + } + #error_reporting($e); + flush(); + + //$ADODB_COUNTRECS=false; + $rs=$db->Execute('select * from ADOXYZ order by id'); + if($rs === false) $create = true; + else $rs->Close(); + + //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ"); + + if ($create) { + if (false && $db->databaseType == 'ibase') { + print "Please create the following table for testing:

$createtab

"; + return; + } else { + $db->debug = 99; + # $e = error_reporting(E_ALL-E_WARNING); + $db->Execute($createtab); + # error_reporting($e); + } + } + #error_reporting(E_ALL); + echo "

Testing Metatypes

"; + $t = $db->MetaType('varchar'); + if ($t != 'C') Err("Bad Metatype for varchar"); + + $rs = $db->Execute("delete from ADOXYZ"); // some ODBC drivers will fail the drop so we delete + if ($rs) { + if(! $rs->EOF) print "Error: RecordSet returned by Execute('delete...') should show EOF

"; + $rs->Close(); + } else print "err=".$db->ErrorMsg(); + + print "

Test select on empty table, FetchField when EOF, and GetInsertSQL

"; + $rs = $db->Execute("select id,firstname from ADOXYZ where id=9999"); + if ($rs && !$rs->EOF) print "Error: RecordSet returned by Execute(select...') on empty table should show EOF

"; + if ($rs->EOF && (($ox = $rs->FetchField(0)) && !empty($ox->name))) { + $record['id'] = 99; + $record['firstname'] = 'John'; + $sql = $db->GetInsertSQL($rs, $record); + if (strtoupper($sql) != strtoupper("INSERT INTO ADOXYZ ( id, firstname ) VALUES ( 99, 'John' )")) Err("GetInsertSQL does not work on empty table: $sql"); + } else { + Err("FetchField does not work on empty recordset, meaning GetInsertSQL will fail..."); + } + if ($rs) $rs->Close(); + flush(); + //$db->debug=true; + print "

Testing Commit: "; + $time = $db->DBDate(time()); + if (!$db->BeginTrans()) { + print 'Transactions not supported

'; + if ($db->hasTransactions) Err("hasTransactions should be false"); + } else { /* COMMIT */ + if (!$db->hasTransactions) Err("hasTransactions should be true"); + if ($db->transCnt != 1) Err("Invalid transCnt = $db->transCnt (should be 1)"); + $rs = $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (99,'Should Not','Exist (Commit)',$time)"); + if ($rs && $db->CommitTrans()) { + $rs->Close(); + $rs = $db->Execute("select * from ADOXYZ where id=99"); + if ($rs === false || $rs->EOF) { + print 'Data not saved

'; + $rs = $db->Execute("select * from ADOXYZ where id=99"); + print_r($rs); + die(); + } else print 'OK

'; + if ($rs) $rs->Close(); + } else { + if (!$rs) { + print "Insert failed

"; + $db->RollbackTrans(); + } else print "Commit failed

"; + } + if ($db->transCnt != 0) Err("Invalid transCnt = $db->transCnt (should be 0)"); + + /* ROLLBACK */ + if (!$db->BeginTrans()) print "

Error in BeginTrans()

"; + print "

Testing Rollback: "; + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values (100,'Should Not','Exist (Rollback)',$time)"); + if ($db->RollbackTrans()) { + $rs = $db->Execute("select * from ADOXYZ where id=100"); + if ($rs && !$rs->EOF) print 'Fail: Data should rollback

'; + else print 'OK

'; + if ($rs) $rs->Close(); + } else + print "Commit failed

"; + + $rs = $db->Execute('delete from ADOXYZ where id>50'); + if ($rs) $rs->Close(); + + if ($db->transCnt != 0) Err("Invalid transCnt = $db->transCnt (should be 0)"); + } + + if (1) { + print "

Testing MetaDatabases()

"; + print_r( $db->MetaDatabases()); + + print "

Testing MetaTables() and MetaColumns()

"; + $a = $db->MetaTables(); + if ($a===false) print "MetaTables not supported

"; + else { + print "Array of tables and views: "; + foreach($a as $v) print " ($v) "; + print '

'; + } + + $a = $db->MetaTables('VIEW'); + if ($a===false) print "MetaTables not supported (views)

"; + else { + print "Array of views: "; + foreach($a as $v) print " ($v) "; + print '

'; + } + + $a = $db->MetaTables(false,false,'aDo%'); + if ($a===false) print "MetaTables not supported (mask)

"; + else { + print "Array of ado%: "; + foreach($a as $v) print " ($v) "; + print '

'; + } + + $a = $db->MetaTables('TABLE'); + if ($a===false) print "MetaTables not supported

"; + else { + print "Array of tables: "; + foreach($a as $v) print " ($v) "; + print '

'; + } + + $db->debug=0; + $rez = $db->MetaColumns("NOSUCHTABLEHERE"); + if ($rez !== false) { + Err("MetaColumns error handling failed"); + var_dump($rez); + } + $db->debug=1; + $a = $db->MetaColumns('ADOXYZ'); + if ($a===false) print "MetaColumns not supported

"; + else { + print "

Columns of ADOXYZ:
"; + foreach($a as $v) {print_r($v); echo "
";} + echo "
"; + } + + print "

Testing MetaIndexes

"; + + $a = $db->MetaIndexes(('ADOXYZ'),true); + if ($a===false) print "MetaIndexes not supported

"; + else { + print "

Indexes of ADOXYZ:
"; + adodb_pr($a); + echo "
"; + } + print "

Testing MetaPrimaryKeys

"; + $a = $db->MetaPrimaryKeys('ADOXYZ'); + var_dump($a); + } + $rs = $db->Execute('delete from ADOXYZ'); + if ($rs) $rs->Close(); + + $db->debug = false; + + + switch ($db->databaseType) { + case 'vfp': + + if (0) { + // memo test + $rs = $db->Execute("select data from memo"); + rs2html($rs); + } + break; + + case 'postgres7': + case 'postgres64': + case 'postgres': + case 'ibase': + print "

Encode=".$db->BlobEncode("abc\0d\"' +ef")."

";//' + + print "

Testing Foreign Keys

"; + $arr = $db->MetaForeignKeys('ADOXYZ',false,true); + print_r($arr); + if (!$arr) Err("No MetaForeignKeys"); + break; + + case 'odbc_mssql': + case 'mssqlpo': + print "

Testing Foreign Keys

"; + $arr = $db->MetaForeignKeys('Orders',false,true); + print_r($arr); + if (!$arr) Err("Bad MetaForeignKeys"); + if ($db->databaseType == 'odbc_mssql') break; + + case 'mssql': + + +/* +ASSUME Northwind available... + +CREATE PROCEDURE SalesByCategory + @CategoryName nvarchar(15), @OrdYear nvarchar(4) = '1998' +AS +IF @OrdYear != '1996' AND @OrdYear != '1997' AND @OrdYear != '1998' +BEGIN + SELECT @OrdYear = '1998' +END + +SELECT ProductName, + TotalPurchase=ROUND(SUM(CONVERT(decimal(14,2), OD.Quantity * (1-OD.Discount) * OD.UnitPrice)), 0) +FROM [Order Details] OD, Orders O, Products P, Categories C +WHERE OD.OrderID = O.OrderID + AND OD.ProductID = P.ProductID + AND P.CategoryID = C.CategoryID + AND C.CategoryName = @CategoryName + AND SUBSTRING(CONVERT(nvarchar(22), O.OrderDate, 111), 1, 4) = @OrdYear +GROUP BY ProductName +ORDER BY ProductName +GO + + +CREATE PROCEDURE ADODBTestSP +@a nvarchar(25) +AS +SELECT GETDATE() AS T, @a AS A +GO +*/ + print "

Testing Stored Procedures for mssql

"; + $saved = $db->debug; + $db->debug=true; + $assoc = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $cmd = $db->PrepareSP('ADODBTestSP'); + $ss = "You should see me in the output."; + $db->InParameter($cmd,$ss,'a'); + $rs = $db->Execute($cmd); + #var_dump($rs->fields); + echo $rs->fields['T']." --- ".$rs->fields['A']."---
"; + + $cat = 'Dairy Products'; + $yr = '1998'; + + $stmt = $db->PrepareSP('SalesByCategory'); + $db->InParameter($stmt,$cat,'CategoryName'); + $db->InParameter($stmt,$yr,'OrdYear'); + $rs = $db->Execute($stmt); + rs2html($rs); + + $cat = 'Grains/Cereals'; + $yr = 1998; + + $stmt = $db->PrepareSP('SalesByCategory'); + $db->InParameter($stmt,$cat,'CategoryName'); + $db->InParameter($stmt,$yr,'OrdYear'); + $rs = $db->Execute($stmt); + rs2html($rs); + + $ADODB_FETCH_MODE = $assoc; + + /* + Test out params - works in PHP 4.2.3 and 4.3.3 and 4.3.8 but not 4.3.0: + + CREATE PROCEDURE at_date_interval + @days INTEGER, + @start VARCHAR(20) OUT, + @end VARCHAR(20) OUT + AS + BEGIN + set @start = CONVERT(VARCHAR(20), getdate(), 101) + set @end =CONVERT(VARCHAR(20), dateadd(day, @days, getdate()), 101 ) + END + GO + */ + $db->debug=1; + $stmt = $db->PrepareSP('at_date_interval'); + $days = 10; + $begin_date = ''; + $end_date = ''; + $db->InParameter($stmt,$days,'days', 4, SQLINT4); + $db->OutParameter($stmt,$begin_date,'start', 20, SQLVARCHAR ); + $db->OutParameter($stmt,$end_date,'end', 20, SQLVARCHAR ); + $db->Execute($stmt); + if (empty($begin_date) or empty($end_date) or $begin_date == $end_date) { + Err("MSSQL SP Test for OUT Failed"); + print "begin=$begin_date end=$end_date

"; + } else print "(Today +10days) = (begin=$begin_date end=$end_date)

"; + + $db->debug = $saved; + break; + case 'oci8': + case 'oci8po': + + if (0) { + $t = getmicrotime(); + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $arr = $db->GetArray('select * from abalone_tree'); + $arr = $db->GetArray('select * from abalone_tree'); + $arr = $db->GetArray('select * from abalone_tree'); + echo "

t = ",getmicrotime() - $t,"

"; + die(); + } + + # cleanup + $db->Execute("delete from photos where id=99 or id=1"); + $db->Execute("insert into photos (id) values(1)"); + $db->Execute("update photos set photo=null,descclob=null where id=1"); + + $saved = $db->debug; + $db->debug=true; + + + + /* + CREATE TABLE PHOTOS + ( + ID NUMBER(16) primary key, + PHOTO BLOB, + DESCRIPTION VARCHAR2(4000 BYTE), + DESCCLOB CLOB + ); + + INSERT INTO PHOTOS (ID) VALUES(1); + */ + $s = ''; + for ($i = 0; $i <= 500; $i++) { + $s .= '1234567890'; + } + + $sql = "INSERT INTO photos ( ID, photo) ". + "VALUES ( :id, empty_blob() )". + " RETURNING photo INTO :xx"; + + + $blob_data = $s; + $id = 99; + + $stmt = $db->PrepareSP($sql); + $db->InParameter($stmt, $id, 'id'); + $blob = $db->InParameter($stmt, $s, 'xx',-1, OCI_B_BLOB); + $db->StartTrans(); + $result = $db->Execute($stmt); + $db->CompleteTrans(); + + $s2= $db->GetOne("select photo from photos where id=99"); + echo "
---$s2"; + if ($s !== $s2) Err("insert blob does not match"); + + print "

Testing Blob: size=".strlen($s)."

"; + $ok = $db->Updateblob('photos','photo',$s,'id=1'); + if (!$ok) Err("Blob failed 1"); + else { + $s2= $db->GetOne("select photo from photos where id=1"); + if ($s !== $s2) Err("updateblob does not match"); + } + + print "

Testing Clob: size=".strlen($s)."

"; + $ok = $db->UpdateClob('photos','descclob',$s,'id=1'); + if (!$ok) Err("Clob failed 1"); + else { + $s2= $db->GetOne("select descclob from photos where id=1"); + if ($s !== $s2) Err("updateclob does not match"); + } + + + $s = ''; + $s2 = ''; + print "

Testing Foreign Keys

"; + $arr = $db->MetaForeignKeys('emp','scott'); + print_r($arr); + if (!$arr) Err("Bad MetaForeignKeys"); +/* +-- TEST PACKAGE +-- "Set scan off" turns off substitution variables. +Set scan off; + +CREATE OR REPLACE PACKAGE Adodb AS +TYPE TabType IS REF CURSOR RETURN TAB%ROWTYPE; +PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR); +PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) ; +PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR); +PROCEDURE data_in(input IN VARCHAR); +PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER); +END Adodb; +/ + + +CREATE OR REPLACE PACKAGE BODY Adodb AS +PROCEDURE open_tab (tabcursor IN OUT TabType,tablenames IN VARCHAR) IS + BEGIN + OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames; + END open_tab; + + PROCEDURE open_tab2 (tabcursor IN OUT TabType,tablenames IN OUT VARCHAR) IS + BEGIN + OPEN tabcursor FOR SELECT * FROM TAB WHERE tname LIKE tablenames; + tablenames := 'TEST'; + END open_tab2; + +PROCEDURE data_out(input IN VARCHAR, output OUT VARCHAR) IS + BEGIN + output := 'Cinta Hati '||input; + END; + +PROCEDURE data_in(input IN VARCHAR) IS + ignore varchar(1000); + BEGIN + ignore := input; + END; + +PROCEDURE myproc (p1 IN NUMBER, p2 OUT NUMBER) AS +BEGIN +p2 := p1; +END; +END Adodb; +/ + +*/ + + print "

Testing Cursor Variables

"; + $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:zz,'A%'); END;",'zz'); + + if ($rs && !$rs->EOF) { + $v = $db->GetOne("SELECT count(*) FROM tab where tname like 'A%'"); + if ($v == $rs->RecordCount()) print "Test 1 RowCount: OK

"; + else Err("Test 1 RowCount ".$rs->RecordCount().", actual = $v"); + } else { + print "Error in using Cursor Variables 1

"; + } + if ($rs) $rs->Close(); + + print "

Testing Stored Procedures for oci8

"; + + $stmt = $db->PrepareSP("BEGIN adodb.data_out(:a1, :a2); END;"); + $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); + + $stmt = $db->PrepareSP("begin adodb.data_in(:a1); end;"); + $db->InParameter($stmt,$a1,'a1'); + $db->Execute($stmt); + + $db->debug = $saved; + break; + + default: + break; + } + $arr = array( + array(1,'Caroline','Miranda'), + array(2,'John','Lim'), + array(3,'Wai Hun','See') + ); + //$db->debug=1; + print "

Testing Bulk Insert of 3 rows

"; + +// $db->debug=1; +// $db->Execute('select * from table where val=? AND value=?', array('val'=>'http ://www.whatever.com/test?=21', 'value'=>'blabl')); + + + $sql = "insert into ADOXYZ (id,firstname,lastname) values (".$db->Param('0').",".$db->Param('1').",".$db->Param('2').")"; + $db->bulkBind = true; + $db->StartTrans(); + $db->debug=99; + $db->Execute($sql,$arr); + $db->CompleteTrans(); + $db->bulkBind = false; + $rs = $db->Execute('select * from ADOXYZ order by id'); + if (!$rs || $rs->RecordCount() != 3) Err("Bad bulk insert"); + + rs2html($rs); + + $db->Execute('delete from ADOXYZ'); + + print "

Inserting 50 rows

"; + + for ($i = 0; $i < 5; $i++) { + + $time = $db->DBDate(time()); + if (empty($_GET['hide'])) $db->debug = true; + switch($db->databaseType){ + case 'mssqlpo': + case 'mssql': + $sqlt = "CREATE TABLE mytable ( + row1 INT IDENTITY(1,1) NOT NULL, + row2 varchar(16), + PRIMARY KEY (row1))"; + //$db->debug=1; + if (!$db->Execute("delete from mytable")) + $db->Execute($sqlt); + + $ok = $db->Execute("insert into mytable (row2) values ('test')"); + $ins_id=$db->Insert_ID(); + echo "Insert ID=";var_dump($ins_id); + if ($ins_id == 0) Err("Bad Insert_ID()"); + $ins_id2 = $db->GetOne("select row1 from mytable"); + if ($ins_id != $ins_id2) Err("Bad Insert_ID() 2"); + + $arr = array(0=>'Caroline',1=>'Miranda'); + $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,?,?,$time)"; + break; + case 'mysqli': + case 'mysqlt': + case 'mysql': + $sqlt = "CREATE TABLE `mytable` ( + `row1` int(11) NOT NULL auto_increment, + `row2` varchar(16) NOT NULL default '', + PRIMARY KEY (`row1`), + KEY `myindex` (`row1`,`row2`) +) "; + if (!$db->Execute("delete from mytable")) + $db->Execute($sqlt); + + $ok = $db->Execute("insert into mytable (row2) values ('test')"); + $ins_id=$db->Insert_ID(); + echo "Insert ID=";var_dump($ins_id); + if ($ins_id == 0) Err("Bad Insert_ID()"); + $ins_id2 = $db->GetOne("select row1 from mytable"); + if ($ins_id != $ins_id2) Err("Bad Insert_ID() 2"); + + default: + $arr = array(0=>'Caroline',1=>'Miranda'); + $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,?,?,$time)"; + break; + + case 'oci8': + case 'oci805': + $arr = array('first'=>'Caroline','last'=>'Miranda'); + $amt = rand() % 100; + $sql = "insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+0,:first,:last,$time)"; + break; + } + if ($i & 1) { + $sql = $db->Prepare($sql); + } + $rs = $db->Execute($sql,$arr); + + if ($rs === false) Err( 'Error inserting with parameters'); + else $rs->Close(); + $db->debug = false; + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+1,'John','Lim',$time)"); + /*$ins_id=$db->Insert_ID(); + echo "Insert ID=";var_dump($ins_id);*/ + if ($db->databaseType == 'mysql') if ($ins_id == 0) Err('Bad Insert_ID'); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+2,'Mary','Lamb',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+3,'George','Washington',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+4,'Mr. Alan','Tam',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+5,'Alan',".$db->quote("Turing'ton").",$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created)values ($i*10+6,'Serena','Williams',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+7,'Yat Sun','Sun',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+8,'Wai Hun','See',$time )"); + $db->Execute("insert into ADOXYZ (id,firstname,lastname,created) values ($i*10+9,'Steven','Oey',$time )"); + } // for + if (1) { + $db->debug=1; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $cnt = $db->GetOne("select count(*) from ADOXYZ"); + $rs = $db->Execute('update ADOXYZ set id=id+1'); + if (!is_object($rs)) { + print_r($rs); + err("Update should return object"); + } + if (!$rs) err("Update generated error"); + + $nrows = $db->Affected_Rows(); + if ($nrows === false) print "

Affected_Rows() not supported

"; + else if ($nrows != $cnt) print "

Affected_Rows() Error: $nrows returned (should be 50)

"; + else print "

Affected_Rows() passed

"; + } + + if ($db->dataProvider == 'oci8') $array = array('zid'=>1,'zdate'=>date('Y-m-d',time())); + else $array=array(1,date('Y-m-d',time())); + + + #$array = array(1,date('Y-m-d',time())); + $id = $db->GetOne("select id from ADOXYZ + where id=".$db->Param('zid')." and created>=".$db->Param('ZDATE')."", + $array); + if ($id != 1) Err("Bad bind; id=$id"); + else echo "
Bind date/integer 1 passed"; + + $array =array(1,$db->BindDate(time())); + $id = $db->GetOne("select id from ADOXYZ + where id=".$db->Param('0')." and created>=".$db->Param('1')."", + $array); + if ($id != 1) Err("Bad bind; id=$id"); + else echo "
Bind date/integer 2 passed"; + + $db->debug = false; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + ////////////////////////////////////////////////////////////////////////////////////////// + + $rs = $db->Execute("select * from ADOXYZ where firstname = 'not known'"); + if (!$rs || !$rs->EOF) print "

Error on empty recordset

"; + else if ($rs->RecordCount() != 0) { + print "

Error on RecordCount. Should be 0. Was ".$rs->RecordCount()."

"; + print_r($rs->fields); + } + if ($db->databaseType !== 'odbc') { + $rs = $db->Execute("select id,firstname,lastname,created,".$db->random." from ADOXYZ order by id"); + if ($rs) { + if ($rs->RecordCount() != 50) { + print "

RecordCount returns ".$rs->RecordCount().", should be 50

"; + adodb_pr($rs->GetArray()); + $poc = $rs->PO_RecordCount('ADOXYZ'); + if ($poc == 50) print "

    PO_RecordCount passed

"; + else print "

PO_RecordCount returns wrong value: $poc

"; + } else print "

RecordCount() passed

"; + if (isset($rs->fields['firstname'])) print '

The fields columns can be indexed by column name.

'; + else { + Err( '

The fields columns cannot be indexed by column name.

'); + print_r($rs->fields); + } + if (empty($_GET['hide'])) rs2html($rs); + } + else print "

Error in Execute of SELECT with random

"; + } + $val = $db->GetOne("select count(*) from ADOXYZ"); + if ($val == 50) print "

GetOne returns ok

"; + else print "

Fail: GetOne returns $val

"; + + echo "GetRow Test"; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $val1 = $db->GetRow("select count(*) from ADOXYZ"); + $val2 = $db->GetRow("select count(*) from ADOXYZ"); + if ($val1[0] == 50 and sizeof($val1) == 1 and $val2[0] == 50 and sizeof($val2) == 1) print "

GetRow returns ok

"; + else { + print_r($val); + print "

Fail: GetRow returns {$val2[0]}

"; + } + + print "

FetchObject/FetchNextObject Test

"; + $rs = $db->Execute('select * from ADOXYZ'); + if ($rs) { + if (empty($rs->connection)) print "Connection object missing from recordset
"; + + while ($o = $rs->FetchNextObject()) { // calls FetchObject internally + if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) { + print_r($o); + print "

Firstname is not string

"; + break; + } + } + } else { + print "

Failed rs

"; + die("

ADOXYZ table cannot be read - die()"); + } + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + print "

FetchObject/FetchNextObject Test 2

"; + #$db->debug=99; + $rs = $db->Execute('select * from ADOXYZ'); + if (empty($rs->connection)) print "Connection object missing from recordset
"; + print_r($rs->fields); + while ($o = $rs->FetchNextObject()) { // calls FetchObject internally + if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) { + print_r($o); + print "

Firstname is not string

"; + break; + } + } + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + $savefetch = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + + print "

CacheSelectLimit Test...

"; + $rs = $db->CacheSelectLimit('select id, firstname from ADOXYZ order by id',2); + + if (ADODB_ASSOC_CASE == 2 || $db->dataProvider == 'oci8') { + $id = 'ID'; + $fname = 'FIRSTNAME'; + }else { + $id = 'id'; + $fname = 'firstname'; + } + + + if ($rs && !$rs->EOF) { + if (isset($rs->fields[0])) { + Err("ASSOC has numeric fields"); + print_r($rs->fields); + } + if ($rs->fields[$id] != 1) {Err("Error"); print_r($rs->fields);}; + if (trim($rs->fields[$fname]) != 'Caroline') {print Err("Error 2"); print_r($rs->fields);}; + + $rs->MoveNext(); + if ($rs->fields[$id] != 2) {Err("Error 3"); print_r($rs->fields);}; + $rs->MoveNext(); + if (!$rs->EOF) { + Err("Error EOF"); + print_r($rs); + } + } + + print "

FETCH_MODE = ASSOC: Should get 1, Caroline ASSOC_CASE=".ADODB_ASSOC_CASE."

"; + $rs = $db->SelectLimit('select id,firstname from ADOXYZ order by id',2); + if ($rs && !$rs->EOF) { + + if ($rs->fields[$id] != 1) {Err("Error 1"); print_r($rs->fields);}; + if (trim($rs->fields[$fname]) != 'Caroline') {Err("Error 2"); print_r($rs->fields);}; + $rs->MoveNext(); + if ($rs->fields[$id] != 2) {Err("Error 3"); print_r($rs->fields);}; + $rs->MoveNext(); + if (!$rs->EOF) Err("Error EOF"); + else if (is_array($rs->fields) || $rs->fields) { + Err("Error: ## fields should be set to false on EOF"); + print_r($rs->fields); + } + } + + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + print "

FETCH_MODE = NUM: Should get 1, Caroline

"; + $rs = $db->SelectLimit('select id,firstname from ADOXYZ order by id',1); + if ($rs && !$rs->EOF) { + if (isset($rs->fields[$id])) Err("FETCH_NUM has ASSOC fields"); + if ($rs->fields[0] != 1) {Err("Error 1"); print_r($rs->fields);}; + if (trim($rs->fields[1]) != 'Caroline') {Err("Error 2");print_r($rs->fields);}; + $rs->MoveNext(); + if (!$rs->EOF) Err("Error EOF"); + + } + $ADODB_FETCH_MODE = $savefetch; + + $db->debug = false; + print "

GetRowAssoc Upper: Should get 1, Caroline

"; + $rs = $db->SelectLimit('select id,firstname from ADOXYZ order by id',1); + if ($rs && !$rs->EOF) { + $arr = $rs->GetRowAssoc(ADODB_ASSOC_CASE_UPPER); + + if ($arr[strtoupper($id)] != 1) {Err("Error 1");print_r($arr);}; + if (trim($arr[strtoupper($fname)]) != 'Caroline') {Err("Error 2"); print_r($arr);}; + $rs->MoveNext(); + if (!$rs->EOF) Err("Error EOF"); + + } + print "

GetRowAssoc Lower: Should get 1, Caroline

"; + $rs = $db->SelectLimit('select id,firstname from ADOXYZ order by id',1); + if ($rs && !$rs->EOF) { + $arr = $rs->GetRowAssoc(ADODB_ASSOC_CASE_LOWER); + if ($arr['id'] != 1) {Err("Error 1"); print_r($arr);}; + if (trim($arr['firstname']) != 'Caroline') {Err("Error 2"); print_r($arr);}; + + } + + print "

GetCol Test

"; + $col = $db->GetCol('select distinct firstname from ADOXYZ order by 1'); + if (!is_array($col)) Err("Col size is wrong"); + if (trim($col[0]) != 'Alan' or trim($col[9]) != 'Yat Sun') Err("Col elements wrong"); + + + $col = $db->CacheGetCol('select distinct firstname from ADOXYZ order by 1'); + if (!is_array($col)) Err("Col size is wrong"); + if (trim($col[0]) != 'Alan' or trim($col[9]) != 'Yat Sun') Err("Col elements wrong"); + + $db->debug = true; + + + echo "

Date Update Test

"; + $zdate = date('Y-m-d',time()+3600*24); + $zdate = $db->DBDate($zdate); + $db->Execute("update ADOXYZ set created=$zdate where id=1"); + $row = $db->GetRow("select created,firstname from ADOXYZ where id=1"); + print_r($row); echo "
"; + + + + print "

SelectLimit Distinct Test 1: Should see Caroline, John and Mary

"; + $rs = $db->SelectLimit('select distinct * from ADOXYZ order by id',3); + + + if ($rs && !$rs->EOF) { + if (trim($rs->fields[1]) != 'Caroline') Err("Error 1 (exp Caroline), ".$rs->fields[1]); + $rs->MoveNext(); + + if (trim($rs->fields[1]) != 'John') Err("Error 2 (exp John), ".$rs->fields[1]); + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'Mary') Err("Error 3 (exp Mary),".$rs->fields[1]); + $rs->MoveNext(); + if (! $rs->EOF) Err("Error EOF"); + //rs2html($rs); + } else Err("Failed SelectLimit Test 1"); + + print "

SelectLimit Test 2: Should see Mary, George and Mr. Alan

"; + $rs = $db->SelectLimit('select * from ADOXYZ order by id',3,2); + if ($rs && !$rs->EOF) { + if (trim($rs->fields[1]) != 'Mary') Err("Error 1 - No Mary, instead: ".$rs->fields[1]); + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'George')Err("Error 2 - No George, instead: ".$rs->fields[1]); + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'Mr. Alan') Err("Error 3 - No Mr. Alan, instead: ".$rs->fields[1]); + $rs->MoveNext(); + if (! $rs->EOF) Err("Error EOF"); + // rs2html($rs); + } + else Err("Failed SelectLimit Test 2 ". ($rs ? 'EOF':'no RS')); + + print "

SelectLimit Test 3: Should see Wai Hun and Steven

"; + $db->debug=1; + global $A; $A=1; + $rs = $db->SelectLimit('select * from ADOXYZ order by id',-1,48); + $A=0; + if ($rs && !$rs->EOF) { + if (empty($rs->connection)) print "Connection object missing from recordset
"; + if (trim($rs->fields[1]) != 'Wai Hun') Err("Error 1 ".$rs->fields[1]); + $rs->MoveNext(); + if (trim($rs->fields[1]) != 'Steven') Err("Error 2 ".$rs->fields[1]); + $rs->MoveNext(); + if (! $rs->EOF) { + Err("Error EOF"); + } + //rs2html($rs); + } + else Err("Failed SelectLimit Test 3"); + $db->debug = false; + + + $rs = $db->Execute("select * from ADOXYZ order by id"); + print "

Testing Move()

"; + if (!$rs)Err( "Failed Move SELECT"); + else { + if (!$rs->Move(2)) { + if (!$rs->canSeek) print "

$db->databaseType: Move(), MoveFirst() nor MoveLast() not supported.

"; + else print '

RecordSet->canSeek property should be set to false

'; + } else { + $rs->MoveFirst(); + if (trim($rs->Fields("firstname")) != 'Caroline') { + print "

$db->databaseType: MoveFirst failed -- probably cannot scroll backwards

"; + } + else print "MoveFirst() OK
"; + + // Move(3) tests error handling -- MoveFirst should not move cursor + $rs->Move(3); + if (trim($rs->Fields("firstname")) != 'George') { + print '

'.$rs->Fields("id")."$db->databaseType: Move(3) failed

"; + } else print "Move(3) OK
"; + + $rs->Move(7); + if (trim($rs->Fields("firstname")) != 'Yat Sun') { + print '

'.$rs->Fields("id")."$db->databaseType: Move(7) failed

"; + print_r($rs); + } else print "Move(7) OK
"; + if ($rs->EOF) Err("Move(7) is EOF already"); + $rs->MoveLast(); + if (trim($rs->Fields("firstname")) != 'Steven'){ + print '

'.$rs->Fields("id")."$db->databaseType: MoveLast() failed

"; + print_r($rs); + }else print "MoveLast() OK
"; + $rs->MoveNext(); + if (!$rs->EOF) err("Bad MoveNext"); + if ($rs->canSeek) { + $rs->Move(3); + if (trim($rs->Fields("firstname")) != 'George') { + print '

'.$rs->Fields("id")."$db->databaseType: Move(3) after MoveLast failed

"; + + } else print "Move(3) after MoveLast() OK
"; + } + + print "

Empty Move Test"; + $rs = $db->Execute("select * from ADOXYZ where id > 0 and id < 0"); + $rs->MoveFirst(); + if (!$rs->EOF || $rs->fields) Err("Error in empty move first"); + } + } + + $rs = $db->Execute('select * from ADOXYZ where id = 2'); + if ($rs->EOF || !is_array($rs->fields)) Err("Error in select"); + $rs->MoveNext(); + if (!$rs->EOF) Err("Error in EOF (xx) "); + // $db->debug=true; + print "

Testing ADODB_FETCH_ASSOC and concat: concat firstname and lastname

"; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + if ($db->dataProvider == 'postgres') { + $sql = "select ".$db->Concat('cast(firstname as varchar)',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ"; + $rs = $db->Execute($sql); + } else { + $sql = "select distinct ".$db->Concat('firstname',$db->qstr(' '),'lastname')." as fullname,id,".$db->sysTimeStamp." as d from ADOXYZ"; + $rs = $db->Execute($sql); + } + if ($rs) { + if (empty($_GET['hide'])) rs2html($rs); + } else { + Err( "Failed Concat:".$sql); + } + $ADODB_FETCH_MODE = $save; + print "
Testing GetArray() "; + //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + + $rs = $db->Execute("select * from ADOXYZ order by id"); + if ($rs) { + $arr = $rs->GetArray(10); + if (sizeof($arr) != 10 || trim($arr[1][1]) != 'John' || trim($arr[1][2]) != 'Lim') print $arr[1][1].' '.$arr[1][2]."   ERROR
"; + else print " OK
"; + } + + $arr = $db->GetArray("select x from ADOXYZ"); + $e = $db->ErrorMsg(); $e2 = $db->ErrorNo(); + echo "Testing error handling, should see illegal column 'x' error=$e ($e2)
"; + if (!$e || !$e2) Err("Error handling did not work"); + print "Testing FetchNextObject for 1 object "; + $rs = $db->Execute("select distinct lastname,firstname from ADOXYZ where firstname='Caroline'"); + $fcnt = 0; + if ($rs) + while ($o = $rs->FetchNextObject()) { + $fcnt += 1; + } + if ($fcnt == 1) print " OK
"; + else print "FAILED
"; + + $stmt = $db->Prepare("select * from ADOXYZ where id < 3"); + $rs = $db->Execute($stmt); + if (!$rs) Err("Prepare failed"); + else { + $arr = $rs->GetArray(); + if (!$arr) Err("Prepare failed 2"); + if (sizeof($arr) != 2) Err("Prepare failed 3"); + } + print "Testing GetAssoc() "; + + + if ($db->dataProvider == 'mysql') { + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $arr = $db->GetAssoc("SELECT 'adodb', '0'"); + var_dump($arr); + die(); + } + + $savecrecs = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + //$arr = $db->GetArray("select lastname,firstname from ADOXYZ"); + //print_r($arr); + print "
"; + $rs = $db->Execute("select distinct lastname,firstname,created from ADOXYZ"); + + if ($rs) { + $arr = $rs->GetAssoc(); + //print_r($arr); + if (empty($arr['See']) || trim(reset($arr['See'])) != 'Wai Hun') print $arr['See']."   ERROR
"; + else print " OK 1"; + } + + $arr = $db->GetAssoc("select distinct lastname,firstname from ADOXYZ"); + if ($arr) { + //print_r($arr); + if (empty($arr['See']) || trim($arr['See']) != 'Wai Hun') print $arr['See']."   ERROR
"; + else print " OK 2
"; + } + // Comment this out to test countrecs = false + $ADODB_COUNTRECS = $savecrecs; + $db->debug=1; + $query = $db->Prepare("select count(*) from ADOXYZ"); + $rs = $db->CacheExecute(10,$query); + if (reset($rs->fields) != 50) echo Err("$cnt wrong for Prepare/CacheGetOne"); + + for ($loop=0; $loop < 1; $loop++) { + print "Testing GetMenu() and CacheExecute
"; + $db->debug = true; + $rs = $db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + + + + + if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu('menu','Steven').'
'; + else print " Fail
"; + $rs = $db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + + if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu('menu','Steven',false).'
'; + else print " Fail
"; + + $rs = $db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + + if ($rs) print ' 1st line set to **** , Steven selected: '. $rs->GetMenu('menu','Steven','1st:****').'
'; + else print " Fail
"; + + + + $rs = $db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) print ' Multiple, Alan selected: '. $rs->GetMenu('menu','Alan',false,true).'
'; + else print " Fail
"; + print '


'; + + $rs = $db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) { + print ' Multiple, Alan and George selected: '. $rs->GetMenu('menu',array('Alan','George'),false,true); + if (empty($rs->connection)) print "Connection object missing from recordset
"; + } else print " Fail
"; + print '


'; + + print "Testing GetMenu3()
"; + $rs = $db->Execute("select ".$db->Concat('firstname',"'-'",'id').",id, lastname from ADOXYZ order by lastname,id"); + if ($rs) print "Grouped Menu: ".$rs->GetMenu3('name'); + else Err('Grouped Menu GetMenu3()'); + print "
"; + + print "Testing GetMenu2()
"; + $rs = $db->CacheExecute(4,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) print 'With blanks, Steven selected:'. $rs->GetMenu2('menu',('Oey')).'
'; + else print " Fail
"; + $rs = $db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ"); + if ($rs) print ' No blanks, Steven selected: '. $rs->GetMenu2('menu',('Oey'),false).'
'; + else print " Fail
"; + } + echo "

CacheExecute

"; + + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $rs = $db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ"); + print_r($rs->fields); echo $rs->fetchMode;echo "
"; + echo $rs->Fields($fname); + + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $rs = $db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ"); + print_r($rs->fields);echo "
"; + echo $rs->Fields($fname); + $db->debug = false; + + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + // phplens + + $sql = 'select * from ADOXYZ where 0=1'; + echo "

**Testing '$sql' (phplens compat 1)

"; + $rs = $db->Execute($sql); + if (!$rs) err( "No recordset returned for '$sql'"); + if (!$rs->FieldCount()) err( "No fields returned for $sql"); + if (!$rs->FetchField(1)) err( "FetchField failed for $sql"); + + $sql = 'select * from ADOXYZ order by 1'; + echo "

**Testing '$sql' (phplens compat 2)

"; + $rs = $db->Execute($sql); + if (!$rs) err( "No recordset returned for '$sql'
".$db->ErrorMsg()."
"); + + + $sql = 'select * from ADOXYZ order by 1,1'; + echo "

**Testing '$sql' (phplens compat 3)

"; + $rs = $db->Execute($sql); + if (!$rs) err( "No recordset returned for '$sql'
".$db->ErrorMsg()."
"); + + + // Move + $rs1 = $db->Execute("select id from ADOXYZ where id <= 2 order by 1"); + $rs2 = $db->Execute("select id from ADOXYZ where id = 3 or id = 4 order by 1"); + + if ($rs1) $rs1->MoveLast(); + if ($rs2) $rs2->MoveLast(); + + if (empty($rs1) || empty($rs2) || $rs1->fields[0] != 2 || $rs2->fields[0] != 4) { + $a = $rs1->fields[0]; + $b = $rs2->fields[0]; + print "

Error in multiple recordset test rs1=$a rs2=$b (should be rs1=2 rs2=4)

"; + } else + print "

Testing multiple recordsets OK

"; + + + echo "

GenID test: "; + for ($i=1; $i <= 10; $i++) + echo "($i: ",$val = $db->GenID($db->databaseType.'abcseq7' ,5), ") "; + if ($val == 0) Err("GenID not supported"); + + if ($val) { + $db->DropSequence('abc_seq2'); + $db->CreateSequence('abc_seq2'); + $val = $db->GenID('abc_seq2'); + $db->DropSequence('abc_seq2'); + $db->CreateSequence('abc_seq2'); + $val = $db->GenID('abc_seq2'); + if ($val != 1) Err("Drop and Create Sequence not supported ($val)"); + } + echo "

"; + + if (substr($db->dataProvider,0,3) != 'notused') { // used to crash ado + $sql = "select firstnames from ADOXYZ"; + print "

Testing execution of illegal statement: $sql

"; + if ($db->Execute($sql) === false) { + print "

This returns the following ErrorMsg(): ".$db->ErrorMsg()." and ErrorNo(): ".$db->ErrorNo().'

'; + } else + print "

Error in error handling -- Execute() should return false

"; + } else + print "

ADO skipped error handling of bad select statement

"; + + print "

ASSOC TEST 2
"; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $rs = $db->query('select * from ADOXYZ order by id'); + if ($ee = $db->ErrorMsg()) { + Err("Error message=$ee"); + } + if ($ee = $db->ErrorNo()) { + Err("Error No = $ee"); + } + print_r($rs->fields); + for($i=0;$i<$rs->FieldCount();$i++) + { + $fld=$rs->FetchField($i); + print "
Field name is ".$fld->name; + print " ".$rs->Fields($fld->name); + } + + + print "

BOTH TEST 2
"; + if ($db->dataProvider == 'ado') { + print "ADODB_FETCH_BOTH not supported for dataProvider=".$db->dataProvider."
"; + } else { + $ADODB_FETCH_MODE = ADODB_FETCH_BOTH; + $rs = $db->query('select * from ADOXYZ order by id'); + for($i=0;$i<$rs->FieldCount();$i++) + { + $fld=$rs->FetchField($i); + print "
Field name is ".$fld->name; + print " ".$rs->Fields($fld->name); + } + } + + print "

NUM TEST 2
"; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $rs = $db->query('select * from ADOXYZ order by id'); + for($i=0;$i<$rs->FieldCount();$i++) + { + $fld=$rs->FetchField($i); + print "
Field name is ".$fld->name; + print " ".$rs->Fields($fld->name); + } + + print "

ASSOC Test of SelectLimit
"; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $rs = $db->selectlimit('select * from ADOXYZ order by id',3,4); + $cnt = 0; + while ($rs && !$rs->EOF) { + $cnt += 1; + if (!isset($rs->fields['firstname'])) { + print "
ASSOC returned numeric field

"; + break; + } + $rs->MoveNext(); + } + if ($cnt != 3) print "
Count should be 3, instead it was $cnt

"; + + + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($db->sysDate) { + $saved = $db->debug; + $db->debug = 1; + $rs = $db->Execute("select {$db->sysDate} from ADOXYZ where id=1"); + if (ADORecordSet::UnixDate(date('Y-m-d')) != $rs->UnixDate($rs->fields[0])) { + print "

Invalid date {$rs->fields[0]}

"; + } else + print "

Passed \$sysDate test ({$rs->fields[0]})

"; + + print_r($rs->FetchField(0)); + print time(); + $db->debug=$saved; + } else { + print "

\$db->sysDate not defined

"; + } + + print "

Test CSV

"; + include_once('../toexport.inc.php'); + //$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $rs = $db->SelectLimit('select id,firstname,lastname,created,\'He, he\' he,\'"\' q from ADOXYZ',10); + + print "
";
+	print rs2csv($rs);
+	print "
"; + + $rs = $db->SelectLimit('select id,firstname,lastname,created,\'The "young man", he said\' from ADOXYZ',10); + + if (PHP_VERSION < 5) { + print "
";
+		rs2tabout($rs);
+		print "
"; + } + #print " CacheFlush "; + #$db->CacheFlush(); + + $date = $db->SQLDate('d-m-M-Y-\QQ h:i:s A'); + $sql = "SELECT $date from ADOXYZ"; + print "

Test SQLDate: ".htmlspecialchars($sql)."

"; + $rs = $db->SelectLimit($sql,1); + $d = date('d-m-M-Y-').'Q'.(ceil(date('m')/3.0)).date(' h:i:s A'); + if (!$rs) Err("SQLDate query returned no recordset"); + else if ($d != $rs->fields[0]) Err("SQLDate 1 failed expected:
act:$d
sql:".$rs->fields[0]); + + $dbdate = $db->DBDate("1974-02-25"); + if (substr($db->dataProvider, 0, 8) == 'postgres') { + $dbdate .= "::TIMESTAMP"; + } + + $date = $db->SQLDate('d-m-M-Y-\QQ h:i:s A', $dbdate); + $sql = "SELECT $date from ADOXYZ"; + print "

Test SQLDate: ".htmlspecialchars($sql)."

"; + $db->debug=1; + $rs = $db->SelectLimit($sql,1); + $ts = ADOConnection::UnixDate('1974-02-25'); + $d = date('d-m-M-Y-',$ts).'Q'.(ceil(date('m',$ts)/3.0)).date(' h:i:s A',$ts); + if (!$rs) { + Err("SQLDate query returned no recordset"); + echo $db->ErrorMsg(),'
'; + } else if ($d != reset($rs->fields)) { + Err("SQLDate 2 failed expected:
act:$d
sql:".$rs->fields[0].'
'.$db->ErrorMsg()); + } + + + print "

Test Filter

"; + $db->debug = 1; + + $rs = $db->SelectLimit('select * from ADOXYZ where id < 3 order by id'); + + $rs = RSFilter($rs,'do_strtolower'); + if (trim($rs->fields[1]) != 'caroline' && trim($rs->fields[2]) != 'miranda') { + err('**** RSFilter failed'); + print_r($rs->fields); + } + + rs2html($rs); + + $db->debug=1; + + + print "

Test Replace

"; + + $ret = $db->Replace('ADOXYZ', + array('id'=>1,'firstname'=>'Caroline','lastname'=>'Miranda'), + array('id'), + $autoq = true); + if (!$ret) echo "

Error in replacing existing record

"; + else { + $saved = $db->debug; + $db->debug = 0; + $savec = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = true; + $rs = $db->Execute('select * FROM ADOXYZ where id=1'); + $db->debug = $saved; + if ($rs->RecordCount() != 1) { + $cnt = $rs->RecordCount(); + rs2html($rs); + print "Error - Replace failed, count=$cnt

"; + } + $ADODB_COUNTRECS = $savec; + } + $ret = $db->Replace('ADOXYZ', + array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'), + array('id','firstname'), + $autoq = true); + if ($ret != 2) print "Replace failed: "; + print "test A return value=$ret (2 expected)

"; + + $ret = $db->Replace('ADOXYZ', + array('id'=>1000,'firstname'=>'Sherazade','lastname'=>'Al-Rashid'), + 'id', + $autoq = true); + if ($ret != 1) + if ($db->dataProvider == 'ibase' && $ret == 2); + else print "Replace failed: "; + print "test B return value=$ret (1 or if ibase then 2 expected)

"; + + print "

rs2rs Test

"; + + $rs = $db->Execute('select * from ADOXYZ where id>= 1 order by id'); + $rs = $db->_rs2rs($rs); + $rs->valueX = 'X'; + $rs->MoveNext(); + $rs = $db->_rs2rs($rs); + if (!isset($rs->valueX)) err("rs2rs does not preserve array recordsets"); + if (reset($rs->fields) != 1) err("rs2rs does not move to first row: id=".reset($rs->fields)); + + ///////////////////////////////////////////////////////////// + include_once('../pivottable.inc.php'); + print "

Pivot Test

"; + $db->debug=true; + $sql = PivotTableSQL( + $db, # adodb connection + 'ADOXYZ', # tables + 'firstname', # row fields + 'lastname', # column fields + false, # join + 'ID', # sum + 'Sum ', # label for sum + 'sum', # aggregate function + true + ); + $rs = $db->Execute($sql); + if ($rs) rs2html($rs); + else Err("Pivot sql error"); + + $pear = false; //true; + $db->debug=false; + + if ($pear) { + // PEAR TESTS BELOW + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + include_once "PEAR.php"; + $rs = $db->query('select * from ADOXYZ where id>0 and id<10 order by id'); + + $i = 0; + if ($rs && !$rs->EOF) { + while ($arr = $rs->fetchRow()) { + $i++; + //print "$i "; + if ($arr[0] != $i) { + print_r($arr); + print "

PEAR DB emulation error 1.

"; + $pear = false; + break; + } + } + $rs->Close(); + } + + + if ($i != $db->GetOne('select count(*) from ADOXYZ where id>0 and id<10')) { + print "

PEAR DB emulation error 1.1 EOF ($i)

"; + $pear = false; + } + + $rs = $db->limitQuery('select * from ADOXYZ where id>0 order by id',$i=3,$top=3); + $i2 = $i; + if ($rs && !$rs->EOF) { + + while (!is_object($rs->fetchInto($arr))) { + $i2++; + + // print_r($arr); + // print "$i ";print_r($arr); + if ($arr[0] != $i2) { + print "

PEAR DB emulation error 2.

"; + $pear = false; + break; + } + } + $rs->Close(); + } + if ($i2 != $i+$top) { + print "

PEAR DB emulation error 2.1 EOF (correct=$i+$top, actual=$i2)

"; + $pear = false; + } + } + if ($pear) print "

PEAR DB emulation passed.

"; + flush(); + + + $rs = $db->SelectLimit("select ".$db->sysDate." from ADOXYZ",1); + $date = $rs->fields[0]; + if (!$date) Err("Bad sysDate"); + else { + $ds = $db->UserDate($date,"d m Y"); + if ($ds != date("d m Y")) Err("Bad UserDate: ".$ds.' expected='.date("d m Y")); + else echo "Passed UserDate: $ds

"; + } + $db->debug=1; + if ($db->dataProvider == 'oci8') + $rs = $db->SelectLimit("select to_char(".$db->sysTimeStamp.",'YYYY-MM-DD HH24:MI:SS') from ADOXYZ",1); + else + $rs = $db->SelectLimit("select ".$db->sysTimeStamp." from ADOXYZ",1); + $date = $rs->fields[0]; + if (!$date) Err("Bad sysTimeStamp"); + else { + $ds = $db->UserTimeStamp($date,"H \\h\\r\\s-d m Y"); + if ($ds != date("H \\h\\r\\s-d m Y")) Err("Bad UserTimeStamp: ".$ds.", correct is ".date("H \\h\\r\\s-d m Y")); + else echo "Passed UserTimeStamp: $ds

"; + + $date = 100; + $ds = $db->UserTimeStamp($date,"H \\h\\r\\s-d m Y"); + $ds2 = date("H \\h\\r\\s-d m Y",$date); + if ($ds != $ds2) Err("Bad UserTimeStamp 2: $ds: $ds2"); + else echo "Passed UserTimeStamp 2: $ds

"; + } + flush(); + + if ($db->hasTransactions) { + $db->debug=1; + echo "

Testing StartTrans CompleteTrans

"; + $db->raiseErrorFn = false; + + $db->SetTransactionMode('SERIALIZABLE'); + $db->StartTrans(); + $rs = $db->Execute('select * from notable'); + $db->StartTrans(); + $db->BeginTrans(); + $db->Execute("update ADOXYZ set firstname='Carolx' where id=1"); + $db->CommitTrans(); + $db->CompleteTrans(); + $rez = $db->CompleteTrans(); + $db->SetTransactionMode(''); + $db->debug=0; + if ($rez !== false) { + if (is_null($rez)) Err("Error: _transOK not modified"); + else Err("Error: CompleteTrans (1) should have failed"); + } else { + $name = $db->GetOne("Select firstname from ADOXYZ where id=1"); + if ($name == "Carolx") Err("Error: CompleteTrans (2) should have failed"); + else echo "

-- Passed StartTrans test1 - rolling back

"; + } + + $db->StartTrans(); + $db->BeginTrans(); + $db->Execute("update ADOXYZ set firstname='Carolx' where id=1"); + $db->RollbackTrans(); + $rez = $db->CompleteTrans(); + if ($rez !== true) Err("Error: CompleteTrans (1) should have succeeded"); + else { + $name = $db->GetOne("Select firstname from ADOXYZ where id=1"); + if (trim($name) != "Carolx") Err("Error: CompleteTrans (2) should have succeeded, returned name=$name"); + else echo "

-- Passed StartTrans test2 - commiting

"; + } + } + flush(); + $saved = $db->debug; + $db->debug=1; + $cnt = _adodb_getcount($db, 'select * from ADOXYZ where firstname in (select firstname from ADOXYZ)'); + echo "Count= $cnt"; + $db->debug=$saved; + + global $TESTERRS; + $debugerr = true; + + global $ADODB_LANG;$ADODB_LANG = 'fr'; + $db->debug = false; + $TESTERRS = 0; + $db->raiseErrorFn = 'adodb_test_err'; + global $ERRNO; // from adodb_test_err + $db->Execute('select * from nowhere'); + $metae = $db->MetaError($ERRNO); + if ($metae !== DB_ERROR_NOSUCHTABLE) print "

MetaError=".$metae." wrong, should be ".DB_ERROR_NOSUCHTABLE."

"; + else print "

MetaError ok (".DB_ERROR_NOSUCHTABLE."): ".$db->MetaErrorMsg($metae)."

"; + if ($TESTERRS != 1) print "raiseErrorFn select nowhere failed
"; + $rs = $db->Execute('select * from ADOXYZ'); + if ($debugerr) print " Move"; + $rs->Move(100); + $rs->_queryID = false; + if ($debugerr) print " MoveNext"; + $rs->MoveNext(); + if ($debugerr) print " $rs=false"; + $rs = false; + + flush(); + + print "

SetFetchMode() tests

"; + $db->SetFetchMode(ADODB_FETCH_ASSOC); + $rs = $db->SelectLimit('select firstname from ADOXYZ',1); + if (!isset($rs->fields['firstname'])) Err("BAD FETCH ASSOC"); + + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $rs = $db->SelectLimit('select firstname from ADOXYZ',1); + //var_dump($rs->fields); + if (!isset($rs->fields['firstname'])) Err("BAD FETCH ASSOC"); + + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $db->SetFetchMode(ADODB_FETCH_NUM); + $rs = $db->SelectLimit('select firstname from ADOXYZ',1); + if (!isset($rs->fields[0])) Err("BAD FETCH NUM"); + + flush(); + + print "

Test MetaTables again with SetFetchMode()

"; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $db->SetFetchMode(ADODB_FETCH_ASSOC); + print_r($db->MetaTables()); + print "

"; + + //////////////////////////////////////////////////////////////////// + + print "

Testing Bad Connection

"; + flush(); + + if (true || PHP_VERSION < 5) { + if ($db->dataProvider == 'odbtp') $db->databaseType = 'odbtp'; + $conn = NewADOConnection($db->databaseType); + $conn->raiseErrorFn = 'adodb_test_err'; + if (1) $conn->PConnect('abc','baduser','badpassword'); + if ($TESTERRS == 2) print "raiseErrorFn tests passed
"; + else print "raiseErrorFn tests failed ($TESTERRS)
"; + + flush(); + } + //////////////////////////////////////////////////////////////////// + + global $nocountrecs; + + if (isset($nocountrecs) && $ADODB_COUNTRECS) err("Error: \$ADODB_COUNTRECS is set"); + if (empty($nocountrecs) && $ADODB_COUNTRECS==false) err("Error: \$ADODB_COUNTRECS is not set"); + + flush(); +?> +

+
 
+

+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)
"; +} + +//-------------------------------------------------------------------------------------- + + +@set_time_limit(240); // increase timeout + +include("../tohtml.inc.php"); +include("../adodb.inc.php"); +include("../rsfilter.inc.php"); + +/* White Space Check */ + +if (isset($_SERVER['argv'][1])) { + //print_r($_SERVER['argv']); + $_GET[$_SERVER['argv'][1]] = 1; +} + +if (@$_SERVER['COMPUTERNAME'] == 'TIGRESS') { + CheckWS('mysqlt'); + CheckWS('postgres'); + CheckWS('oci8po'); + + CheckWS('firebird'); + CheckWS('sybase'); + if (!ini_get('safe_mode')) CheckWS('informix'); + + CheckWS('ado_mssql'); + CheckWS('ado_access'); + CheckWS('mssql'); + + CheckWS('vfp'); + CheckWS('sqlanywhere'); + CheckWS('db2'); + CheckWS('access'); + CheckWS('odbc_mssql'); + CheckWS('firebird15'); + // + CheckWS('oracle'); + CheckWS('proxy'); + CheckWS('fbsql'); + print "White Space Check complete

"; +} +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; + } +} + +?> + +ADODB Testing + +

ADODB Test

+ +This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO). +There is also support for Sybase, PostgreSQL.

+For the latest version of ADODB, visit
adodb.sourceforge.net.

+ +Test GetInsertSQL/GetUpdateSQL   + Sessions   + Paging   + Perf Monitor

+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 00000000..eb3b0258 --- /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 00000000..78c7c775 --- /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 00000000..7a5d821c --- /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 00000000..e46bbc1d --- /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().'
'; +} + +if (0) { + $conn = ADONewConnection("oci8"); // create a connection + $conn->debug=1; + $conn->PConnect("falcon", "scott", "tiger", "juris8.ecosystem.natsoft.com.my"); // connect to MySQL, testdb + print $conn->databaseType.':'.$conn->GenID(); +} + +if (0) { + $conn = ADONewConnection("ibase"); // create a connection + $conn->debug=1; + $conn->Connect("localhost:c:\\Interbase\\Examples\\Database\\employee.gdb", "sysdba", "masterkey", ""); // connect to MySQL, testdb + print $conn->databaseType.':'.$conn->GenID().'
'; +} + +if (0) { + $conn = ADONewConnection('postgres'); + $conn->debug=1; + @$conn->PConnect("susetikus","tester","test","test"); + print $conn->databaseType.':'.$conn->GenID().'
'; +} diff --git a/vendor/adodb/adodb-php/tests/test_rs_array.php b/vendor/adodb/adodb-php/tests/test_rs_array.php new file mode 100644 index 00000000..547b20ad --- /dev/null +++ b/vendor/adodb/adodb-php/tests/test_rs_array.php @@ -0,0 +1,46 @@ +InitArray($array,$typearr); + +while (!$rs->EOF) { + print_r($rs->fields);echo "
"; + $rs->MoveNext(); +} + +echo "
1 Seek
"; +$rs->Move(1); +while (!$rs->EOF) { + print_r($rs->fields);echo "
"; + $rs->MoveNext(); +} + +echo "
2 Seek
"; +$rs->Move(2); +while (!$rs->EOF) { + print_r($rs->fields);echo "
"; + $rs->MoveNext(); +} + +echo "
3 Seek
"; +$rs->Move(3); +while (!$rs->EOF) { + print_r($rs->fields);echo "
"; + $rs->MoveNext(); +} + + + +die(); diff --git a/vendor/adodb/adodb-php/tests/testcache.php b/vendor/adodb/adodb-php/tests/testcache.php new file mode 100644 index 00000000..87f6d51a --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testcache.php @@ -0,0 +1,30 @@ + + +PConnect('nwind'); +} else { + $db = ADONewConnection('mysql'); + $db->PConnect('mangrove','root','','xphplens'); +} +if (isset($cache)) $rs = $db->CacheExecute(120,'select * from products'); +else $rs = $db->Execute('select * from products'); + +$arr = $rs->GetArray(); +print sizeof($arr); diff --git a/vendor/adodb/adodb-php/tests/testdatabases.inc.php b/vendor/adodb/adodb-php/tests/testdatabases.inc.php new file mode 100644 index 00000000..f9f000a6 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testdatabases.inc.php @@ -0,0 +1,478 @@ + + +
+
+> Access
+> Interbase
+> MSSQL
+> MySQL
+> MySQL ODBC
+> MySQLi +
+
> SQLite
+> MySQL Proxy
+> Oracle (oci8)
+> PostgreSQL
+> PostgreSQL 9
+> PostgreSQL ODBC
+
+> PgSQL PDO
+> MySQL PDO
+> SQLite PDO
+> Access PDO
+> MSSQL PDO
+ +> OCI PDO
+ +
> DB2
+> VFP+ODBTP
+> ADO (for mssql and access)
+> $ADODB_COUNTRECS=false
+> No SQL Logging
+> ADOdb time test +
+ + + +FETCH MODE IS NOT ADODB_FETCH_DEFAULT"; + +if (isset($nocountrecs)) $ADODB_COUNTRECS = false; + +// cannot test databases below, but we include them anyway to check +// if they parse ok... + +if (sizeof($_GET) || !isset($_SERVER['HTTP_HOST'])) { + echo "
"; + ADOLoadCode2("sybase"); + ADOLoadCode2("postgres"); + ADOLoadCode2("postgres7"); + ADOLoadCode2("firebird"); + ADOLoadCode2("borland_ibase"); + ADOLoadCode2("informix"); + ADOLoadCode2('mysqli'); + if (defined('ODBC_BINMODE_RETURN')) { + ADOLoadCode2("sqlanywhere"); + ADOLoadCode2("access"); + } + ADOLoadCode2("mysql"); + ADOLoadCode2("oci8"); +} + +function ADOLoadCode2($d) +{ + ADOLoadCode($d); + $c = ADONewConnection($d); + echo "Loaded $d ",($c ? 'ok' : 'extension not installed'),"
"; +} + +flush(); + +// dregad 2014-04-15 added serial field to avoid error with lastval() +$pg_test_table = "create table ADOXYZ (id integer, firstname char(24), lastname varchar,created date, ser serial)"; +$pg_hostname = 'localhost'; +$pg_user = 'tester'; +$pg_password = 'test'; +$pg_database = 'northwind'; +$pg_errmsg = "ERROR: PostgreSQL requires a database called '$pg_database' " + . "on server '$pg_hostname', user '$pg_user', password '$pg_password'.
"; + +if (!empty($testpostgres)) { + //ADOLoadCode("postgres"); + + $db = ADONewConnection('postgres'); + print "

Connecting $db->databaseType...

"; + if ($db->Connect($pg_hostname, $pg_user, $pg_password, $pg_database)) { + testdb($db, $pg_test_table); + } else { + print $pg_errmsg . $db->ErrorMsg(); + } +} + +if (!empty($testpostgres9)) { + //ADOLoadCode("postgres"); + + $db = ADONewConnection('postgres9'); + print "

Connecting $db->databaseType...

"; + if ($db->Connect($pg_hostname, $pg_user, $pg_password, $pg_database)) { + testdb($db, $pg_test_table); + } else { + print $pg_errmsg . $db->ErrorMsg(); + } +} + +if (!empty($testpgodbc)) { + + $db = ADONewConnection('odbc'); + $db->hasTransactions = false; + print "

Connecting $db->databaseType...

"; + + if ($db->PConnect('Postgresql')) { + $db->hasTransactions = true; + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); + } else print "ERROR: PostgreSQL requires a database called test on server, user tester, password test.
".$db->ErrorMsg(); +} + +if (!empty($testibase)) { + //$_GET['nolog'] = true; + $db = ADONewConnection('firebird'); + print "

Connecting $db->databaseType...

"; + if ($db->PConnect("localhost:d:\\firebird\\151\\examples\\EMPLOYEE.fdb", "sysdba", "masterkey", "")) + testdb($db,"create table ADOXYZ (id integer, firstname char(24), lastname char(24),price numeric(12,2),created date)"); + else print "ERROR: Interbase test requires a database called employee.gdb".'
'.$db->ErrorMsg(); + +} + + +if (!empty($testsqlite)) { + $path =urlencode('d:\inetpub\adodb\sqlite.db'); + $dsn = "sqlite://$path/"; + $db = ADONewConnection($dsn); + //echo $dsn; + + //$db = ADONewConnection('sqlite'); + + + if ($db && $db->PConnect("d:\\inetpub\\adodb\\sqlite.db", "", "", "")) { + print "

Connecting $db->databaseType...

"; + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + } else + print "ERROR: SQLite"; + +} + +if (!empty($testpdopgsql)) { + $connstr = "pgsql:dbname=test"; + $u = 'tester';$p='test'; + $db = ADONewConnection('pdo'); + print "

Connecting $db->databaseType...

"; + $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); +} + +if (!empty($testpdomysql)) { + $connstr = "mysql:dbname=northwind"; + $u = 'root';$p=''; + $db = ADONewConnection('pdo'); + print "

Connecting $db->databaseType...

"; + $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); + + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); +} + +if (!empty($testpdomssql)) { + $connstr = "mssql:dbname=northwind"; + $u = 'sa';$p='natsoft'; + $db = ADONewConnection('pdo'); + print "

Connecting $db->databaseType...

"; + $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); + + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); +} + +if (!empty($testpdosqlite)) { + $connstr = "sqlite:d:/inetpub/adodb/sqlite-pdo.db3"; + $u = '';$p=''; + $db = ADONewConnection('pdo'); + $db->hasTransactions = false; + print "

Connecting $db->databaseType...

"; + $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); +} + +if (!empty($testpdoaccess)) { + $connstr = 'odbc:nwind'; + $u = '';$p=''; + $db = ADONewConnection('pdo'); + $db->hasTransactions = false; + print "

Connecting $db->databaseType...

"; + $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); +} + +if (!empty($testpdoora)) { + $connstr = 'oci:'; + $u = 'scott';$p='natsoft'; + $db = ADONewConnection('pdo'); + #$db->hasTransactions = false; + print "

Connecting $db->databaseType...

"; + $db->Connect($connstr,$u,$p) || die("CONNECT FAILED"); + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); +} + +// REQUIRES ODBC DSN CALLED nwind +if (!empty($testaccess)) { + $db = ADONewConnection('access'); + print "

Connecting $db->databaseType...

"; + $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; + $dsn = "nwind"; + $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$access;Uid=Admin;Pwd=;"; + + //$dsn = 'Provider=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=' . $access . ';'; + if ($db->PConnect($dsn, "", "", "")) + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + else print "ERROR: Access test requires a Windows ODBC DSN=nwind, Access driver"; + +} + +if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS + + $db = ADONewConnection("ado_access"); + print "

Connecting $db->databaseType...

"; + + $access = 'd:\inetpub\wwwroot\php\NWIND.MDB'; + $myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;' + . 'DATA SOURCE=' . $access . ';'; + //. 'USER ID=;PASSWORD=;'; + $_GET['nolog'] = 1; + if ($db->PConnect($myDSN, "", "", "")) { + print "ADO version=".$db->_connectionID->version."
"; + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + } else print "ERROR: Access test requires a Access database $access".'
'.$db->ErrorMsg(); + +} + +if (!empty($testvfp)) { // ODBC + $db = ADONewConnection('vfp'); + print "

Connecting $db->databaseType...

";flush(); + + if ( $db->PConnect("vfp-adoxyz")) { + testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)"); + } else print "ERROR: Visual FoxPro test requires a Windows ODBC DSN=vfp-adoxyz, VFP driver"; + + echo "
"; + $db = ADONewConnection('odbtp'); + + if ( $db->PConnect('localhost','DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBF;SOURCEDB=d:\inetpub\adodb;EXCLUSIVE=NO;')) { + print "

Connecting $db->databaseType...

";flush(); + testdb($db,"create table d:\\inetpub\\adodb\\ADOXYZ (id int, firstname char(24), lastname char(24),created date)"); + } else print "ERROR: Visual FoxPro odbtp requires a Windows ODBC DSN=vfp-adoxyz, VFP driver"; + +} + + +// REQUIRES MySQL server at localhost with database 'test' +if (!empty($testmysql)) { // MYSQL + + + if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; + else $server = "mangrove"; + $user = 'root'; $password = ''; $database = 'northwind'; + $db = ADONewConnection("mysqlt://$user:$password@$server/$database?persist"); + print "

Connecting $db->databaseType...

"; + + if (true || $db->PConnect($server, "root", "", "northwind")) { + //$db->Execute("DROP TABLE ADOXYZ") || die('fail drop'); + //$db->debug=1;$db->Execute('drop table ADOXYZ'); + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) Type=InnoDB"); + } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
'.$db->ErrorMsg(); +} + +// REQUIRES MySQL server at localhost with database 'test' +if (!empty($testmysqli)) { // MYSQL + + $db = ADONewConnection('mysqli'); + print "

Connecting $db->databaseType...

"; + if (PHP_VERSION >= 5 || $_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; + else $server = "mangrove"; + if ($db->PConnect($server, "root", "", "northwind")) { + //$db->debug=1;$db->Execute('drop table ADOXYZ'); + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)"); + } else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
'.$db->ErrorMsg(); +} + + +// REQUIRES MySQL server at localhost with database 'test' +if (!empty($testmysqlodbc)) { // MYSQL + + $db = ADONewConnection('odbc'); + $db->hasTransactions = false; + print "

Connecting $db->databaseType...

"; + if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; + else $server = "mangrove"; + if ($db->PConnect('mysql', "root", "")) + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); + else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
'.$db->ErrorMsg(); +} + +if (!empty($testproxy)){ + $db = ADONewConnection('proxy'); + print "

Connecting $db->databaseType...

"; + if ($_SERVER['HTTP_HOST'] == 'localhost') $server = 'localhost'; + + if ($db->PConnect('http://localhost/php/phplens/adodb/server.php')) + testdb($db, + "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb"); + else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'
'.$db->ErrorMsg(); + +} + +ADOLoadCode('oci805'); +ADOLoadCode("oci8po"); + +if (!empty($testoracle)) { + $dsn = "oci8";//://scott:natsoft@kk2?persist"; + $db = ADONewConnection($dsn );//'oci8'); + + //$db->debug=1; + print "

Connecting $db->databaseType...

"; + if ($db->Connect('mobydick', "scott", "natsoft",'SID=mobydick')) + testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); + else + print "ERROR: Oracle test requires an Oracle server setup with scott/natsoft".'
'.$db->ErrorMsg(); + +} +ADOLoadCode("oracle"); // no longer supported +if (false && !empty($testoracle)) { + + $db = ADONewConnection(); + print "

Connecting $db->databaseType...

"; + if ($db->PConnect("", "scott", "tiger", "natsoft.domain")) + testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); + else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'
'.$db->ErrorMsg(); + +} + +ADOLoadCode("odbc_db2"); // no longer supported +if (!empty($testdb2)) { + if (PHP_VERSION>=5.1) { + $db = ADONewConnection("db2"); + print "

Connecting $db->databaseType...

"; + + #$db->curMode = SQL_CUR_USE_ODBC; + #$dsn = "driver={IBM db2 odbc DRIVER};Database=test;hostname=localhost;port=50000;protocol=TCPIP; uid=natsoft; pwd=guest"; + if ($db->Connect('localhost','natsoft','guest','test')) { + testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); + } else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'
'.$db->ErrorMsg(); + } else { + $db = ADONewConnection("odbc_db2"); + print "

Connecting $db->databaseType...

"; + + $dsn = "db2test"; + #$db->curMode = SQL_CUR_USE_ODBC; + #$dsn = "driver={IBM db2 odbc DRIVER};Database=test;hostname=localhost;port=50000;protocol=TCPIP; uid=natsoft; pwd=guest"; + if ($db->Connect($dsn)) { + testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); + } else print "ERROR: DB2 test requires an server setup with odbc data source db2_sample".'
'.$db->ErrorMsg(); + } +echo "
"; +flush(); + $dsn = "driver={IBM db2 odbc DRIVER};Database=sample;hostname=localhost;port=50000;protocol=TCPIP; uid=root; pwd=natsoft"; + + $db = ADONewConnection('odbtp'); + if ($db->Connect('127.0.0.1',$dsn)) { + + $db->debug=1; + $arr = $db->GetArray( "||SQLProcedures" ); adodb_pr($arr); + $arr = $db->GetArray( "||SQLProcedureColumns|||GET_ROUTINE_SAR" );adodb_pr($arr); + + testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)"); + } else echo ("ERROR Connection"); + echo $db->ErrorMsg(); +} + + +$server = 'localhost'; + + + +ADOLoadCode("mssqlpo"); +if (false && !empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC + $db = ADONewConnection("mssqlpo"); + //$db->debug=1; + print "

Connecting $db->databaseType...

"; + + $ok = $db->Connect('','sa','natsoft','northwind'); + echo $db->ErrorMsg(); + if ($ok /*or $db->PConnect("mangrove", "sa", "natsoft", "ai")*/) { + AutoDetect_MSSQL_Date_Order($db); + // $db->Execute('drop table adoxyz'); + testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); + } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='$server', userid='adodb', password='natsoft', database='ai'".'
'.$db->ErrorMsg(); + +} + + +ADOLoadCode('odbc_mssql'); +if (!empty($testmssql)) { // MS SQL Server via ODBC + $db = ADONewConnection(); + + print "

Connecting $db->databaseType...

"; + + $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;"; + $dsn = 'condor'; + if ($db->PConnect($dsn, "sa", "natsoft", "")) { + testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); + } + else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup"; + +} + +ADOLoadCode("ado_mssql"); +if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less + + $db = ADONewConnection("ado_mssql"); + //$db->debug=1; + print "

Connecting DSN-less $db->databaseType...

"; + + $myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};" + . "SERVER=$server;DATABASE=NorthWind;UID=adodb;PWD=natsoft;Trusted_Connection=No"; + + + if ($db->PConnect($myDSN, "", "", "")) + testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); + else print "ERROR: MSSQL test 2 requires MS SQL 7"; + +} + +if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider + + $db = ADONewConnection("ado_mssql"); + print "

Connecting DSN-less OLEDB Provider $db->databaseType...

"; + //$db->debug=1; + $myDSN="SERVER=localhost;DATABASE=northwind;Trusted_Connection=yes"; + if ($db->PConnect($myDSN, "adodb", "natsoft", 'SQLOLEDB')) { + testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)"); + } else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'"; + +} + + +if (extension_loaded('odbtp') && !empty($testmssql)) { // MS SQL Server via ODBC + $db = ADONewConnection('odbtp'); + + $dsn = "PROVIDER=MSDASQL;Driver={SQL Server};Server=$server;Database=northwind;uid=adodb;pwd=natsoft"; + + if ($db->PConnect('localhost',$dsn, "", "")) { + print "

Connecting $db->databaseType...

"; + testdb($db,"create table ADOXYZ (id int, firstname char(24) null, lastname char(24) null,created datetime null)"); + } + else print "ERROR: MSSQL test 1 requires a MS SQL 7 server setup with DSN setup"; + +} + + +print "

Tests Completed

"; diff --git a/vendor/adodb/adodb-php/tests/testgenid.php b/vendor/adodb/adodb-php/tests/testgenid.php new file mode 100644 index 00000000..3310734a --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testgenid.php @@ -0,0 +1,35 @@ +Execute("drop table $table"); + //$db->debug=true; + + $ctr = 5000; + $lastnum = 0; + + while (--$ctr >= 0) { + $num = $db->GenID($table); + if ($num === false) { + print "GenID returned false"; + break; + } + if ($lastnum + 1 == $num) print " $num "; + else { + print " $num "; + flush(); + } + $lastnum = $num; + } +} diff --git a/vendor/adodb/adodb-php/tests/testmssql.php b/vendor/adodb/adodb-php/tests/testmssql.php new file mode 100644 index 00000000..733f0d45 --- /dev/null +++ b/vendor/adodb/adodb-php/tests/testmssql.php @@ -0,0 +1,77 @@ +Connect('127.0.0.1','adodb','natsoft','northwind') or die('Fail'); + +$conn->debug =1; +$query = 'select * from products'; +$conn->SetFetchMode(ADODB_FETCH_ASSOC); +$rs = $conn->Execute($query); +echo "
";
+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 00000000..5eadc22e --- /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 00000000..1f7b381e --- /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 00000000..947641be --- /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 '
'; +$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 "
"; +} + +$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 00000000..a59f5f2c --- /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 "
"; + $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 00000000..79a66191 --- /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 00000000..8261e1e9 --- /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 00000000..0f81311a --- /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 + + + + + + + + + + + + + +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 diff --git a/vendor/adodb/adodb-php/tests/xmlschema.xml b/vendor/adodb/adodb-php/tests/xmlschema.xml new file mode 100644 index 00000000..ea48ae2b --- /dev/null +++ b/vendor/adodb/adodb-php/tests/xmlschema.xml @@ -0,0 +1,33 @@ + + + + + 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' ) + + + + +
+
\ No newline at end of file diff --git a/e_lib/adodb5/toexport.inc.php b/vendor/adodb/adodb-php/toexport.inc.php similarity index 100% rename from e_lib/adodb5/toexport.inc.php rename to vendor/adodb/adodb-php/toexport.inc.php diff --git a/e_lib/adodb5/tohtml.inc.php b/vendor/adodb/adodb-php/tohtml.inc.php similarity index 100% rename from e_lib/adodb5/tohtml.inc.php rename to vendor/adodb/adodb-php/tohtml.inc.php diff --git a/e_lib/adodb5/xmlschema.dtd b/vendor/adodb/adodb-php/xmlschema.dtd similarity index 100% rename from e_lib/adodb5/xmlschema.dtd rename to vendor/adodb/adodb-php/xmlschema.dtd diff --git a/e_lib/adodb5/xmlschema03.dtd b/vendor/adodb/adodb-php/xmlschema03.dtd similarity index 100% rename from e_lib/adodb5/xmlschema03.dtd rename to vendor/adodb/adodb-php/xmlschema03.dtd diff --git a/e_lib/adodb5/xsl/convert-0.1-0.2.xsl b/vendor/adodb/adodb-php/xsl/convert-0.1-0.2.xsl similarity index 100% rename from e_lib/adodb5/xsl/convert-0.1-0.2.xsl rename to vendor/adodb/adodb-php/xsl/convert-0.1-0.2.xsl diff --git a/e_lib/adodb5/xsl/convert-0.1-0.3.xsl b/vendor/adodb/adodb-php/xsl/convert-0.1-0.3.xsl similarity index 100% rename from e_lib/adodb5/xsl/convert-0.1-0.3.xsl rename to vendor/adodb/adodb-php/xsl/convert-0.1-0.3.xsl diff --git a/e_lib/adodb5/xsl/convert-0.2-0.1.xsl b/vendor/adodb/adodb-php/xsl/convert-0.2-0.1.xsl similarity index 100% rename from e_lib/adodb5/xsl/convert-0.2-0.1.xsl rename to vendor/adodb/adodb-php/xsl/convert-0.2-0.1.xsl diff --git a/e_lib/adodb5/xsl/convert-0.2-0.3.xsl b/vendor/adodb/adodb-php/xsl/convert-0.2-0.3.xsl similarity index 100% rename from e_lib/adodb5/xsl/convert-0.2-0.3.xsl rename to vendor/adodb/adodb-php/xsl/convert-0.2-0.3.xsl diff --git a/e_lib/adodb5/xsl/remove-0.2.xsl b/vendor/adodb/adodb-php/xsl/remove-0.2.xsl similarity index 100% rename from e_lib/adodb5/xsl/remove-0.2.xsl rename to vendor/adodb/adodb-php/xsl/remove-0.2.xsl diff --git a/e_lib/adodb5/xsl/remove-0.3.xsl b/vendor/adodb/adodb-php/xsl/remove-0.3.xsl similarity index 100% rename from e_lib/adodb5/xsl/remove-0.3.xsl rename to vendor/adodb/adodb-php/xsl/remove-0.3.xsl diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index dd37d858..9fcb4a5f 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -8,5 +8,6 @@ $baseDir = dirname($vendorDir); return array( 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', + 'bf9f5270ae66ac6fa0290b4bf47867b7' => $vendorDir . '/adodb/adodb-php/adodb.inc.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 87bea681..36f7cc27 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -9,6 +9,7 @@ class ComposerStaticInit67b09c83b85c3bc0027caefe5bba171a public static $files = array ( 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', + 'bf9f5270ae66ac6fa0290b4bf47867b7' => __DIR__ . '/..' . '/adodb/adodb-php/adodb.inc.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', ); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 27488910..358122c1 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,4 +1,60 @@ [ + { + "name": "adodb/adodb-php", + "version": "v5.20.9", + "version_normalized": "5.20.9.0", + "source": { + "type": "git", + "url": "https://github.com/ADOdb/ADOdb.git", + "reference": "f601748cca1ccb86dfd427620a1692a70e681075" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ADOdb/ADOdb/zipball/f601748cca1ccb86dfd427620a1692a70e681075", + "reference": "f601748cca1ccb86dfd427620a1692a70e681075", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2016-12-21T17:19:42+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "adodb.inc.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "LGPL-2.1" + ], + "authors": [ + { + "name": "John Lim", + "email": "jlim@natsoft.com", + "role": "Author" + }, + { + "name": "Damien Regad", + "role": "Current maintainer" + }, + { + "name": "Mark Newnham", + "role": "Developer" + } + ], + "description": "ADOdb is a PHP database abstraction layer library", + "homepage": "http://adodb.org/", + "keywords": [ + "abstraction", + "database", + "layer", + "library", + "php" + ] + }, { "name": "brandonwamboldt/utilphp", "version": "1.1.0",