home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 June / PCpro_2005_06.ISO / files / opensource / xamp / xampp-win32.exe / xampp / 16tableinfo.phpt < prev    next >
Encoding:
Text File  |  2004-10-01  |  23.5 KB  |  918 lines

  1. --TEST--
  2. DB_driver::tableInfo
  3. --INI--
  4. error_reporting = 2047
  5. --SKIPIF--
  6. <?php
  7.  
  8. /**
  9.  * Calls tableInfo() in various ways and checks to see that the output
  10.  * matches what's expected.
  11.  *
  12.  * These tests account for each DBMS using different column types and
  13.  * reporting back different information.  These differences are accounted
  14.  * for in the <var>$quirks</var> array, which has the following format:
  15.  *
  16.  * <pre>
  17.  * 'driver' => array(
  18.  *     'clob' => DBMS's column type for creating CLOB fields
  19.  *     'date' => DBMS's column type for creating DATE fields
  20.  *     'finds_table' => Can this DBMS determine table names from queries?
  21.  *     'commands' => array(
  22.  *         Extra commands to be passed to PHP's eval() function
  23.  *     )
  24.  *     0 => array(
  25.  *         //  Info expected to be reported for phptest_fk.a
  26.  *         'type' => Column type reported by the DBMS
  27.  *         'len' => Column size reported by the DBMS
  28.  *         'flags' => Flags reported by the DBMS
  29.  *     )
  30.  *     1 => array()  Info expected to be reported for phptest_fk.fk
  31.  *     2 => array()  Info expected to be reported for phptest_fk.c
  32.  *     3 => array()  Info expected to be reported for phptest_fk.d
  33.  *     4 => array()  Info expected to be reported for phptest_fk.e
  34.  *     5 => array()  Info expected to be reported for phptest_fk.f
  35.  *     9 => array()  Info expected to be reported for phptest.d
  36.  * )
  37.  * </pre>
  38.  *
  39.  * @see      DB_common::tableInfo()
  40.  * 
  41.  * @package  DB
  42.  * @version  $Id: 16tableinfo.phpt,v 1.25 2004/09/22 22:16:47 danielc Exp $
  43.  * @category Database
  44.  * @author   Daniel Convissor <danielc@analysisandsolutions.com>
  45.  * @internal
  46.  */
  47.  
  48. error_reporting(E_ALL);
  49. chdir(dirname(__FILE__));
  50. require_once './skipif.inc';
  51. $tableInfo = $db->tableInfo('ajkdslfajoijkadie');
  52. if (DB::isError($tableInfo) && $tableInfo->code == DB_ERROR_NOT_CAPABLE) {
  53.     die("skip $tableInfo->message");
  54. }
  55.  
  56. ?>
  57. --FILE--
  58. <?php
  59.  
  60. //  $Id: 16tableinfo.phpt,v 1.25 2004/09/22 22:16:47 danielc Exp $
  61.  
  62. /**
  63.  * Connect to the database and make the phptest table.
  64.  */
  65. require_once './mktable.inc';
  66.  
  67. /**
  68.  * Local error callback handler.
  69.  *
  70.  * Prints out an error message and kills the process.
  71.  *
  72.  * @param object  $o  PEAR error object automatically passed to this method
  73.  * @return void
  74.  * @see PEAR::setErrorHandling()
  75.  */
  76. function pe($o){
  77.     global $dbh;
  78.  
  79.     if ($o->getMessage() == "DB Error: can't distinguish duplicate field names") {
  80.         print "NOTICE: $dbh->phptype can't distinguish duplicate field names";
  81.         return;
  82.     }
  83.  
  84.     $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  85.     $dbh->query('DROP TABLE phptest');
  86.     $dbh->query('DROP TABLE phptest_fk');
  87.  
  88.     die($o->toString());
  89. }
  90.  
  91. /**
  92.  * Loop through an array returned from tableInfo(), compare the actual
  93.  * contents to the expected contents and print out what is found.
  94.  *
  95.  * @param array   $array  the array to be examined
  96.  * @param string  $field  field index number of $quriks and table
  97.  * @param boolean $query  true if array is from a query or false if array
  98.  *                        is tableInfo()
  99.  * @return void
  100.  */
  101. function examineArrayData($array, $field = false, $query = true) {
  102.     global $dbh, $quirks;
  103.  
  104.     if (!is_array($array)) {
  105.         print "This DMBS didn't produce proper results\n\n\n\n\n";
  106.         return;
  107.     }
  108.  
  109.     foreach ($array as $key => $value) {
  110.         if ($field !== false &&
  111.             isset($quirks[$dbh->phptype][$field][$key]))
  112.         {
  113.             if ($key == 'flags' && $value == '' && $query &&
  114.                 !$quirks[$dbh->phptype]['finds_table'])
  115.             {
  116.                 print "$key ... matched expected value\n";
  117.             } else {
  118.                 if ($quirks[$dbh->phptype][$field][$key] == $value) {
  119.                     print "$key ... matched expected value\n";
  120.                 } else {
  121.                     print "$key ... was '$value' but we expected ";
  122.                     print "'{$quirks[$dbh->phptype][$field][$key]}'\n";
  123.                 }
  124.             }
  125.         } else {
  126.             if ($key == 'table') {
  127.                 if ($field <= 5) {
  128.                     if ($value == 'phptest_fk') {
  129.                         print "$key ... matched expected value\n";
  130.                     } else {
  131.                         if ($value == '' && $query &&
  132.                             !$quirks[$dbh->phptype]['finds_table'])
  133.                         {
  134.                             print "$key ... matched expected value\n";
  135.                         } else {
  136.                             print "$key ... was '$value' but we expected 'phptest_fk'\n";
  137.                         }
  138.                     }
  139.                 } else {
  140.                     if ($value == 'phptest') {
  141.                         print "$key ... matched expected value\n";
  142.                     } else {
  143.                         if ($value == '' && $query &&
  144.                             !$quirks[$dbh->phptype]['finds_table'])
  145.                         {
  146.                             print "$key ... matched expected value\n";
  147.                         } else {
  148.                             print "$key ... was '$value' but we expected 'phptest_fk'\n";
  149.                         }
  150.                     }
  151.                 }
  152.             } else {
  153.                 print "$key => $value\n";
  154.             }
  155.         }
  156.     }
  157. }
  158.  
  159. /**
  160.  * Loop through an array of table info data and return the results.
  161.  *
  162.  * @param array  $array  the array to be examined
  163.  * @return string
  164.  */
  165. function returnArrayData($array) {
  166.     $out = '';
  167.     foreach ($array as $key => $value) {
  168.         $out .= "$key => $value\n";
  169.     }
  170.     return $out;
  171. }
  172.  
  173.  
  174. $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe');
  175.  
  176.  
  177. $quirks = array(
  178.     'ibase' => array(
  179.         'clob' => 'VARCHAR(50)',
  180.         'date' => 'DATE',
  181.         'finds_table' => false,
  182.         'commands' => array(
  183.         ),
  184.         0 => array(
  185.             'type' => 'INTEGER',
  186.             'len' => 4,
  187.             'flags' => 'unique_key not_null',
  188.         ),
  189.         1 => array(
  190.             'type' => 'INTEGER',
  191.             'len' => 4,
  192.             'flags' => 'primary_key not_null',
  193.         ),
  194.         2 => array(
  195.             'type' => 'VARCHAR',
  196.             'len' => 50,
  197.             'flags' => '',
  198.         ),
  199.         3 => array(
  200.             'type' => 'DATE',
  201.             'len' => 4,
  202.             'flags' => 'unique_key not_null',
  203.         ),
  204.         4 => array(
  205.             'type' => 'CHAR',
  206.             'len' => 2,
  207.             'flags' => 'not_null default',
  208.         ),
  209.         5 => array(
  210.             'type' => 'NUMERIC(9,1)',
  211.             'len' => 4,
  212.             'flags' => '',
  213.         ),
  214.         9 => array(
  215.             'type' => 'VARCHAR',
  216.             'len' => 20,
  217.             'flags' => '',
  218.         ),
  219.     ),
  220.  
  221.     'ifx' => array(
  222.         'clob' => 'CHAR(29)',
  223.         'date' => 'CHAR(10)',
  224.         'finds_table' => false,
  225.         'commands' => array(
  226.         ),
  227.         0 => array(
  228.             'type' => 'SQLINT',
  229.             'len' => 4,
  230.             'flags' => 'not_null',
  231.         ),
  232.         1 => array(
  233.             'type' => 'SQLINT',
  234.             'len' => 4,
  235.             'flags' => 'not_null',
  236.         ),
  237.         2 => array(
  238.             'type' => 'SQLCHAR',
  239.             'len' => 29,
  240.             'flags' => '',
  241.         ),
  242.         3 => array(
  243.             'type' => 'SQLCHAR',
  244.             'len' => 10,
  245.             'flags' => 'not_null',
  246.         ),
  247.         4 => array(
  248.             'type' => 'SQLCHAR',
  249.             'len' => 2,
  250.             'flags' => 'not_null',
  251.         ),
  252.         5 => array(
  253.             'type' => 'SQLDECIMAL',
  254.             'len' => 513,
  255.             'flags' => '',
  256.         ),
  257.         9 => array(
  258.             'type' => 'SQLCHAR',
  259.             'len' => 20,
  260.             'flags' => '',
  261.         ),
  262.     ),
  263.  
  264.     'mssql' => array(
  265.         'clob' => 'TEXT',
  266.         'date' => 'SMALLDATETIME',
  267.         'finds_table' => false,
  268.         'commands' => array(
  269.             'ini_set("mssql.datetimeconvert", "Off");',
  270.             '$dbh->query("SET DATEFORMAT ymd");',
  271.         ),
  272.         0 => array(
  273.             'type' => 'int',
  274.             'len' => 4,
  275.             'flags' => 'multiple_key unique_key not_null',
  276.         ),
  277.         1 => array(
  278.             'type' => 'int',
  279.             'len' => 4,
  280.             'flags' => 'primary_key not_null',
  281.         ),
  282.         2 => array(
  283.             'type' => 'text',
  284.             'len' => 4096,
  285.             'flags' => '',
  286.         ),
  287.         3 => array(
  288.             'type' => 'datetime',
  289.             'len' => 4,
  290.             'flags' => 'multiple_key unique_key not_null',
  291.         ),
  292.         4 => array(
  293.             'type' => 'char',
  294.             'len' => 2,
  295.             'flags' => 'not_null',
  296.         ),
  297.         5 => array(
  298.             'type' => 'real',
  299.             'len' => 19,
  300.             'flags' => '',
  301.         ),
  302.         9 => array(
  303.             'type' => 'char',
  304.             'len' => 20,
  305.             'flags' => '',
  306.         ),
  307.     ),
  308.  
  309.     'mysql' => array(
  310.         'clob' => 'TEXT',
  311.         'date' => 'DATE',
  312.         'finds_table' => true,
  313.         'commands' => array(
  314.         ),
  315.         0 => array(
  316.             'type' => 'int',
  317.             'len' => 11,
  318.             'flags' => 'not_null multiple_key',
  319.         ),
  320.         1 => array(
  321.             'type' => 'int',
  322.             'len' => 11,
  323.             'flags' => 'not_null primary_key',
  324.         ),
  325.         2 => array(
  326.             'type' => 'blob',
  327.             'len' => 65535,
  328.             'flags' => 'blob',
  329.         ),
  330.         3 => array(
  331.             'type' => 'date',
  332.             'len' => 10,
  333.             'flags' => 'not_null multiple_key',
  334.         ),
  335.         4 => array(
  336.             'type' => 'string',
  337.             'len' => 2,
  338.             'flags' => 'not_null',
  339.         ),
  340.         5 => array(
  341.             'type' => 'real',
  342.             'len' => 4,
  343.             'flags' => '',
  344.         ),
  345.         9 => array(
  346.             'type' => 'string',
  347.             'len' => 20,
  348.             'flags' => '',
  349.         ),
  350.     ),
  351.  
  352.     'mysqli' => array(
  353.         'clob' => 'TEXT',
  354.         'date' => 'DATE',
  355.         'finds_table' => true,
  356.         'commands' => array(
  357.         ),
  358.         0 => array(
  359.             'type' => 'int',
  360.             'len' => 0,
  361.             'flags' => 'not_null unique_key multiple_key group_by',
  362.         ),
  363.         1 => array(
  364.             'type' => 'int',
  365.             'len' => 0,
  366.             'flags' => 'not_null primary_key',
  367.         ),
  368.         2 => array(
  369.             'type' => 'blob',
  370.             'len' => 0,
  371.             'flags' => 'blob',
  372.         ),
  373.         3 => array(
  374.             'type' => 'date',
  375.             'len' => 0,
  376.             'flags' => 'not_null unique_key multiple_key',
  377.         ),
  378.         4 => array(
  379.             'type' => 'char',
  380.             'len' => 0,
  381.             'flags' => 'not_null',
  382.         ),
  383.         5 => array(
  384.             'type' => 'decimal',
  385.             'len' => 0,
  386.             'flags' => 'group_by',
  387.         ),
  388.         9 => array(
  389.             'type' => 'varchar',
  390.             'len' => 0,
  391.             'flags' => '',
  392.         ),
  393.     ),
  394.  
  395.     'oci8' => array(
  396.         'clob' => 'CLOB',
  397.         'date' => 'DATE',
  398.         'finds_table' => false,
  399.         'commands' => array(
  400.             '$dbh->query("ALTER SESSION SET NLS_DATE_FORMAT = \'YYYY-MM-DD\'");',
  401.         ),
  402.         0 => array(
  403.             'type' => 'NUMBER',
  404.             'len' => 22,
  405.             'flags' => 'not_null',
  406.         ),
  407.         1 => array(
  408.             'type' => 'NUMBER',
  409.             'len' => 22,
  410.             'flags' => 'not_null',
  411.         ),
  412.         2 => array(
  413.             'type' => 'CLOB',
  414.             'len' => 4000,
  415.             'flags' => '',
  416.         ),
  417.         3 => array(
  418.             'type' => 'DATE',
  419.             'len' => 7,
  420.             'flags' => 'not_null',
  421.         ),
  422.         4 => array(
  423.             'type' => 'CHAR',
  424.             'len' => 2,
  425.             'flags' => 'not_null',
  426.         ),
  427.         5 => array(
  428.             'type' => 'NUMBER',
  429.             'len' => 22,
  430.             'flags' => '',
  431.         ),
  432.         9 => array(
  433.             'type' => 'VARCHAR',
  434.             'len' => 20,
  435.             'flags' => '',
  436.         ),
  437.     ),
  438.  
  439.     'pgsql' => array(
  440.         'clob' => 'TEXT',
  441.         'date' => 'DATE',
  442.         'finds_table' => false,
  443.         'commands' => array(
  444.             '$dbh->query("SET DATESTYLE = ISO");',
  445.         ),
  446.         0 => array(
  447.             'type' => 'int4',
  448.             'len' => 4,
  449.             'flags' => 'not_null unique_key multiple_key',
  450.         ),
  451.         1 => array(
  452.             'type' => 'int4',
  453.             'len' => 4,
  454.             'flags' => 'not_null primary_key',
  455.         ),
  456.         2 => array(
  457.             'type' => 'text',
  458.             'len' => -1,
  459.             'flags' => '',
  460.         ),
  461.         3 => array(
  462.             'type' => 'date',
  463.             'len' => 4,
  464.             'flags' => 'not_null unique_key multiple_key',
  465.         ),
  466.         4 => array(
  467.             'type' => 'bpchar',
  468.             'len' => -1,
  469.             'flags' => 'not_null default_%20e',
  470.         ),
  471.         5 => array(
  472.             'type' => 'numeric',
  473.             'len' => -1,
  474.             'flags' => '',
  475.         ),
  476.         9 => array(
  477.             'type' => 'varchar',
  478.             'len' => -1,
  479.             'flags' => '',
  480.         ),
  481.     ),
  482.  
  483.     'sybase' => array(
  484.         'clob' => 'TEXT',
  485.         'date' => 'SMALLDATETIME',
  486.         'finds_table' => false,
  487.         'commands' => array(
  488.             '$dbh->query("SET DATEFORMAT ymd");',
  489.         ),
  490.         0 => array(
  491.             'type' => 'int',
  492.             'len' => 11,
  493.             'flags' => 'multiple_key unique_key',
  494.         ),
  495.         1 => array(
  496.             'type' => 'int',
  497.             'len' => 11,
  498.             'flags' => 'unique_key',
  499.         ),
  500.         2 => array(
  501.             'type' => 'string',
  502.             'len' => 32768,
  503.             'flags' => '',
  504.         ),
  505.         3 => array(
  506.             'type' => 'datetime',
  507.             'len' => 29,
  508.             'flags' => 'multiple_key unique_key',
  509.         ),
  510.         4 => array(
  511.             'type' => 'string',
  512.             'len' => 2,
  513.             'flags' => '',
  514.         ),
  515.         5 => array(
  516.             'type' => 'real',
  517.             'len' => 4,
  518.             'flags' => '',
  519.         ),
  520.         9 => array(
  521.             'type' => 'string',
  522.             'len' => 20,
  523.             'flags' => '',
  524.         ),
  525.     ),
  526. );
  527.  
  528.  
  529. if (!isset($quirks[$dbh->phptype])) {
  530.     die("This test does not yet support $dbh->phptype");
  531. }
  532.  
  533. if (count($quirks[$dbh->phptype]['commands'])) {
  534.     foreach ($quirks[$dbh->phptype]['commands'] as $value) {
  535.         eval($value);
  536.     }
  537. }
  538.  
  539.  
  540. $dbh->query('DELETE FROM phptest');
  541. $dbh->query("INSERT INTO phptest VALUES (1, 'one', 'One', '2001-02-16')");
  542. $dbh->query("INSERT INTO phptest VALUES (2, 'two', 'Two', '2001-02-15')");
  543. $dbh->query("INSERT INTO phptest VALUES (3, 'three', 'Three', '2001-02-14')");
  544.  
  545.  
  546. $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  547. $dbh->query('DROP TABLE phptest_fk');
  548. $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, 'pe');
  549.  
  550.  
  551. // $null is set in mktable.inc
  552.  
  553. $dbh->query("
  554.     CREATE TABLE phptest_fk (
  555.         a INTEGER NOT NULL,
  556.         fk INTEGER NOT NULL,
  557.         c {$quirks[$dbh->phptype]['clob']} $null,
  558.         d {$quirks[$dbh->phptype]['date']} NOT NULL,
  559.         e CHAR(2) DEFAULT ' e' NOT NULL,
  560.         f DECIMAL(2,1) $null,
  561.         PRIMARY KEY (fk),
  562.         UNIQUE (a, d)
  563.     )
  564. ");
  565. $dbh->query("CREATE INDEX thedidx ON phptest_fk (d)");
  566. $dbh->query("INSERT INTO phptest_fk VALUES (10, 1, 'One', '2001-02-16',  'c1', 1.1)");
  567. $dbh->query("INSERT INTO phptest_fk VALUES (20, 2, 'Two', '2001-02-15', 'c2', 2.2)");
  568. $dbh->query("INSERT INTO phptest_fk VALUES (30, 3, 'Three', '2001-02-14', 'c3', 3.3)");
  569.  
  570. function &runQuery() {
  571.     global $dbh, $resultobj;
  572.     $resultobj =& $dbh->query('SELECT phptest_fk.a, phptest_fk.fk,
  573.             phptest_fk.c, phptest_fk.d, phptest_fk.e, phptest_fk.f,
  574.             phptest.a, phptest.b, phptest.c, phptest.d
  575.             FROM phptest_fk, phptest WHERE phptest.a = phptest_fk.fk');
  576.     return $resultobj;
  577. }
  578.  
  579.  
  580. print "\n==========================================\n";
  581. print "Passing result OBJECT to method in DB_<type>.\n";
  582. print "Output = default.\n";
  583. print "------------------------------------------\n";
  584. $resultobj =& runQuery();
  585. $array = $dbh->tableInfo($resultobj);
  586.  
  587. print "\nfirst field:\n";
  588. examineArrayData($array[0], 0);
  589.  
  590. print "\ntenth field:\n";
  591. examineArrayData($array[9], 9);
  592.  
  593.  
  594.  
  595. print "\n==========================================\n";
  596. print "Passing result ID to method in DB_<type>.\n";
  597. print "Output = DB_TABLEINFO_ORDER.\n";
  598. print "------------------------------------------\n";
  599. $resultobj =& runQuery();
  600. $array = $dbh->tableInfo($resultobj->result, DB_TABLEINFO_ORDER);
  601.  
  602. print "\nfirst field:\n";
  603. examineArrayData($array[0], 0);
  604.  
  605. print "\nfourth field:\n";
  606. examineArrayData($array[3], 3);
  607.  
  608. print "\nnum_fields:\n";
  609. print "{$array['num_fields']}\n";
  610.  
  611. print "\norder:\n";
  612. if (is_array($array['order'])) {
  613.     ksort($array['order']);
  614.     examineArrayData($array['order']);
  615. } else {
  616.     print "This DMBS didn't produce proper results\n\n\n\n\n\n\n";
  617. }
  618.  
  619.  
  620.  
  621. print "\n==========================================\n";
  622. print "Passing DB_TABLEINFO_ORDERTABLE to method in DB_result.\n";
  623. print "Output = DB_TABLEINFO_ORDERTABLE.\n";
  624. print "------------------------------------------\n";
  625. $resultobj =& runQuery();
  626. $array = $resultobj->tableInfo(DB_TABLEINFO_ORDERTABLE);
  627. // Free this to keep interbase happy.
  628. $resultobj->free();
  629.  
  630. print "\nfirst field:\n";
  631. examineArrayData($array[0], 0);
  632.  
  633. print "\nfourth field:\n";
  634. examineArrayData($array[3], 3);
  635.  
  636. print "\nnum_fields:\n";
  637. print "{$array['num_fields']}\n";
  638.  
  639.  
  640. print "\nordertable[phptest]:\n";
  641. $expected = 'a => 6
  642. b => 7
  643. c => 8
  644. d => 9
  645. ';
  646. if (isset($array['ordertable']['phptest'])) {
  647.     $actual = returnArrayData($array['ordertable']['phptest']);
  648. } else {
  649.     $actual = '';
  650. }
  651. if ($actual == $expected) {
  652.     print "matched expected values\n";
  653. } else {
  654.     if ($quirks[$dbh->phptype]['finds_table'] === false && $actual == '') {
  655.         print "matched expected values\n";
  656.     } else {
  657.         print "DIDN'T match expected values...\n";
  658.         print "~~~~~~~~\nExpected:\n$expected\n";
  659.         print "~~~~\nActual:\n$actual\n~~~~~~~~\n\n";
  660.     }
  661. }
  662.  
  663.  
  664. print "\nordertable[phptest_fk]:\n";
  665. $expected = 'a => 0
  666. fk => 1
  667. c => 2
  668. d => 3
  669. e => 4
  670. f => 5
  671. ';
  672. if (isset($array['ordertable']['phptest_fk'])) {
  673.     $actual = returnArrayData($array['ordertable']['phptest_fk']);
  674. } else {
  675.     $actual = '';
  676. }
  677. if ($actual == $expected) {
  678.     print "matched expected values\n";
  679. } else {
  680.     if ($quirks[$dbh->phptype]['finds_table'] === false && $actual == '') {
  681.         print "matched expected values\n";
  682.     } else {
  683.         print "DIDN'T match expected values...\n";
  684.         print "~~~~~~~~\nExpected:\n$expected\n";
  685.         print "~~~~\nActual:\n$actual\n~~~~~~~~\n\n";
  686.     }
  687. }
  688.  
  689.  
  690. print "\n==========================================\n";
  691. print "Passing TABLE NAME 'phptest_fk' to method in DB_<driver>.\n";
  692. print "Output = default.\n";
  693. print "------------------------------------------\n";
  694. $array = $dbh->tableInfo('phptest_fk');
  695.  
  696. print "\nfirst field:\n";
  697. examineArrayData($array[0], 0, false);
  698.  
  699. print "\nsecond field:\n";
  700. examineArrayData($array[1], 1, false);
  701.  
  702. print "\nthird field:\n";
  703. examineArrayData($array[2], 2, false);
  704.  
  705. print "\nfourth field:\n";
  706. examineArrayData($array[3], 3, false);
  707.  
  708. print "\nfifth field:\n";
  709. examineArrayData($array[4], 4, false);
  710.  
  711. print "\nsixth field:\n";
  712. examineArrayData($array[5], 5, false);
  713.  
  714.  
  715. print "\n==========================================\n";
  716. print "Passing TABLE NAME 'phptest_fk' to method in DB_<driver>.\n";
  717. print "Output = DB_TABLEINFO_FULL.\n";
  718. print "------------------------------------------\n";
  719. $array = $dbh->tableInfo('phptest_fk', DB_TABLEINFO_FULL);
  720.  
  721. print "\nfirst field:\n";
  722. examineArrayData($array[0], 0, false);
  723.  
  724. print "\norder:\n";
  725. examineArrayData($array['order'], false);
  726.  
  727. print "\nordertable[phptest_fk]:\n";
  728. examineArrayData($array['ordertable']['phptest_fk']);
  729.  
  730.  
  731.  
  732. print "\n==========================================\n";
  733. print "Passing TABLE NAME 'phptest_fk' to method in DB_<driver> AGAIN.\n";
  734. print "Output = DB_TABLEINFO_FULL, lowercasing turned off.\n";
  735. print "------------------------------------------\n";
  736. $dbh->setOption('portability', DB_PORTABILITY_ALL ^ DB_PORTABILITY_LOWERCASE);
  737. $array = $dbh->tableInfo('phptest_fk', DB_TABLEINFO_FULL);
  738.  
  739. // testing non-lowercasing above to ensure program doesn't die.
  740. // lowercase the names here to ensure test uniformity.
  741. $array[0]['table'] = strtolower($array[0]['table']);
  742. $array[0]['name'] = strtolower($array[0]['name']);
  743.  
  744. print "\nfirst field:\n";
  745. examineArrayData($array[0], 0, false);
  746.  
  747.  
  748. $dbh->setErrorHandling(PEAR_ERROR_RETURN);
  749. $dbh->query('DROP TABLE phptest');
  750. $dbh->query('DROP TABLE phptest_fk');
  751.  
  752. ?>
  753. --EXPECT--
  754. ==========================================
  755. Passing result OBJECT to method in DB_<type>.
  756. Output = default.
  757. ------------------------------------------
  758.  
  759. first field:
  760. table ... matched expected value
  761. name => a
  762. type ... matched expected value
  763. len ... matched expected value
  764. flags ... matched expected value
  765.  
  766. tenth field:
  767. table ... matched expected value
  768. name => d
  769. type ... matched expected value
  770. len ... matched expected value
  771. flags ... matched expected value
  772.  
  773. ==========================================
  774. Passing result ID to method in DB_<type>.
  775. Output = DB_TABLEINFO_ORDER.
  776. ------------------------------------------
  777.  
  778. first field:
  779. table ... matched expected value
  780. name => a
  781. type ... matched expected value
  782. len ... matched expected value
  783. flags ... matched expected value
  784.  
  785. fourth field:
  786. table ... matched expected value
  787. name => d
  788. type ... matched expected value
  789. len ... matched expected value
  790. flags ... matched expected value
  791.  
  792. num_fields:
  793. 10
  794.  
  795. order:
  796. a => 6
  797. b => 7
  798. c => 8
  799. d => 9
  800. e => 4
  801. f => 5
  802. fk => 1
  803.  
  804. ==========================================
  805. Passing DB_TABLEINFO_ORDERTABLE to method in DB_result.
  806. Output = DB_TABLEINFO_ORDERTABLE.
  807. ------------------------------------------
  808.  
  809. first field:
  810. table ... matched expected value
  811. name => a
  812. type ... matched expected value
  813. len ... matched expected value
  814. flags ... matched expected value
  815.  
  816. fourth field:
  817. table ... matched expected value
  818. name => d
  819. type ... matched expected value
  820. len ... matched expected value
  821. flags ... matched expected value
  822.  
  823. num_fields:
  824. 10
  825.  
  826. ordertable[phptest]:
  827. matched expected values
  828.  
  829. ordertable[phptest_fk]:
  830. matched expected values
  831.  
  832. ==========================================
  833. Passing TABLE NAME 'phptest_fk' to method in DB_<driver>.
  834. Output = default.
  835. ------------------------------------------
  836.  
  837. first field:
  838. table ... matched expected value
  839. name => a
  840. type ... matched expected value
  841. len ... matched expected value
  842. flags ... matched expected value
  843.  
  844. second field:
  845. table ... matched expected value
  846. name => fk
  847. type ... matched expected value
  848. len ... matched expected value
  849. flags ... matched expected value
  850.  
  851. third field:
  852. table ... matched expected value
  853. name => c
  854. type ... matched expected value
  855. len ... matched expected value
  856. flags ... matched expected value
  857.  
  858. fourth field:
  859. table ... matched expected value
  860. name => d
  861. type ... matched expected value
  862. len ... matched expected value
  863. flags ... matched expected value
  864.  
  865. fifth field:
  866. table ... matched expected value
  867. name => e
  868. type ... matched expected value
  869. len ... matched expected value
  870. flags ... matched expected value
  871.  
  872. sixth field:
  873. table ... matched expected value
  874. name => f
  875. type ... matched expected value
  876. len ... matched expected value
  877. flags ... matched expected value
  878.  
  879. ==========================================
  880. Passing TABLE NAME 'phptest_fk' to method in DB_<driver>.
  881. Output = DB_TABLEINFO_FULL.
  882. ------------------------------------------
  883.  
  884. first field:
  885. table ... matched expected value
  886. name => a
  887. type ... matched expected value
  888. len ... matched expected value
  889. flags ... matched expected value
  890.  
  891. order:
  892. a => 0
  893. fk => 1
  894. c => 2
  895. d => 3
  896. e => 4
  897. f => 5
  898.  
  899. ordertable[phptest_fk]:
  900. a => 0
  901. fk => 1
  902. c => 2
  903. d => 3
  904. e => 4
  905. f => 5
  906.  
  907. ==========================================
  908. Passing TABLE NAME 'phptest_fk' to method in DB_<driver> AGAIN.
  909. Output = DB_TABLEINFO_FULL, lowercasing turned off.
  910. ------------------------------------------
  911.  
  912. first field:
  913. table ... matched expected value
  914. name => a
  915. type ... matched expected value
  916. len ... matched expected value
  917. flags ... matched expected value
  918.