<?php
  include_once '../doc-typo3-funcs.php';
  $doxygen_vars = array(	"title" => "TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/checkconnectionwizard.php Source File",
				"datetime" => "Sat Dec 2 19:22:27 2006",
				"date" => "2 Dec 2006",
				"doxygenversion" => "1.4.6",
				"projectname" => "TYPO3 4.0.1",
				"projectnumber" => "4.0.1"
			);
  get_header($doxygen_vars);
?>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
  <ul>
    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li><a href="classes.html"><span>Classes</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="dirs.html"><span>Directories</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li><a href="examples.html"><span>Examples</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
  </ul></div>
<div class="nav">
<a class="el" href="dir_c8daf1ad746050abf985cc546c89e248.html">typo3_src-4.0.1</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_18071ae4545d8b3e0364d30c0659c74a.html">typo3</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_57bf1ed8249c1fd5b014486d01bcb27a.html">sysext</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_e81b1679233d44b74aed493d6fe8e943.html">adodb</a></div>
<h1>checkconnectionwizard.php</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?php
<a name="l00002"></a>00002 <span class="comment">/***************************************************************</span>
<a name="l00003"></a>00003 <span class="comment">*  Copyright notice</span>
<a name="l00004"></a>00004 <span class="comment">*</span>
<a name="l00005"></a>00005 <span class="comment">*  (c) 2004 Robert Lemke (robert@typo3.org)</span>
<a name="l00006"></a>00006 <span class="comment">*  All rights reserved</span>
<a name="l00007"></a>00007 <span class="comment">*</span>
<a name="l00008"></a>00008 <span class="comment">*  This script is part of the TYPO3 project. The TYPO3 project is</span>
<a name="l00009"></a>00009 <span class="comment">*  free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment">*  it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment">*  the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment">*  (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment">*</span>
<a name="l00014"></a>00014 <span class="comment">*  The GNU General Public License can be found at</span>
<a name="l00015"></a>00015 <span class="comment">*  http://www.gnu.org/copyleft/gpl.html.</span>
<a name="l00016"></a>00016 <span class="comment">*</span>
<a name="l00017"></a>00017 <span class="comment">*  This script is distributed in the hope that it will be useful,</span>
<a name="l00018"></a>00018 <span class="comment">*  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00019"></a>00019 <span class="comment">*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00020"></a>00020 <span class="comment">*  GNU General Public License for more details.</span>
<a name="l00021"></a>00021 <span class="comment">*</span>
<a name="l00022"></a>00022 <span class="comment">*  This copyright notice MUST APPEAR in all copies of the script!</span>
<a name="l00023"></a>00023 <span class="comment">***************************************************************/</span>
<a name="l00024"></a>00024 
<a name="l00044"></a>00044         <span class="comment">// Build TYPO3 enviroment:</span>
<a name="l00045"></a>00045 $BACK_PATH='../../../typo3/';
<a name="l00046"></a>00046 define('TYPO3_MOD_PATH', 'sysext/adodb/');
<a name="l00047"></a>00047 require ($BACK_PATH.'init.php');
<a name="l00048"></a>00048 require ($BACK_PATH.'<span class="keyword">template</span>.php');
<a name="l00049"></a>00049 
<a name="l00050"></a>00050         <span class="comment">// Include ADODB library:</span>
<a name="l00051"></a>00051 require_once(<a class="code" href="classt3lib__extMgm.html#f395b211d97293002bbf92c3802392f5">t3lib_extMgm::extPath</a>('adodb').'adodb/adodb.inc.php');
<a name="l00052"></a>00052 
<a name="l00053"></a>00053         <span class="comment">// Include language labels:</span>
<a name="l00054"></a>00054 $LANG-&gt;includeLLFile('EXT:adodb/locallang_wizard.xml');
<a name="l00055"></a>00055 
<a name="l00063"></a><a class="code" href="classtx__adodb__checkconnectionwizard.html">00063</a> <span class="keyword">class </span><a class="code" href="classtx__adodb__checkconnectionwizard.html">tx_adodb_checkconnectionwizard</a> {
<a name="l00064"></a>00064 
<a name="l00065"></a><a class="code" href="classtx__adodb__checkconnectionwizard.html#53aa36052d72ebc2ed5cf2a18232e018">00065</a>         function <a class="code" href="classtx__adodb__checkconnectionwizard.html#53aa36052d72ebc2ed5cf2a18232e018">main</a>() {
<a name="l00066"></a>00066 
<a name="l00067"></a>00067                 $content = '&lt;html&gt;&lt;body&gt;';
<a name="l00068"></a>00068                 $conf = <a class="code" href="classt3lib__div.html#016d2190758279b2dbb953826c690118">t3lib_div::_GP</a>(<span class="charliteral">'P'</span>);
<a name="l00069"></a>00069 
<a name="l00070"></a>00070                 $conf['md5ID'];
<a name="l00071"></a>00071 
<a name="l00072"></a>00072                 <span class="keywordflow">if</span> ($conf['table'] == 'tx_datasources_datasource') {
<a name="l00073"></a>00073                         $dsRecord = t3lib_beFunc::getRecord($conf['table'], intval($conf['uid']));
<a name="l00074"></a>00074 
<a name="l00075"></a>00075                         <span class="keywordflow">if</span> (is_array ($dsRecord)) {
<a name="l00076"></a>00076                                 $dsArr = <a class="code" href="classt3lib__div.html#4f6203e563def3f905bf40fd217ce705">t3lib_div::xml2array</a> ($dsRecord['configuration']);
<a name="l00077"></a>00077                                 $dsConf = $dsArr['data']['sDEF']['lDEF'];
<a name="l00078"></a>00078 
<a name="l00079"></a>00079                                 $content .= '&lt;p&gt;Trying to connect with Host / DSN &lt;strong&gt;'.htmlspecialchars($dsConf['field_host']['vDEF']).'&lt;/strong&gt; with user &lt;strong&gt;'.htmlspecialchars($dsConf['field_username']['vDEF']).'&lt;/strong&gt; ... ';
<a name="l00080"></a>00080                                 $dbConn = &amp;ADONewConnection($dsConf['field_dbtype']['vDEF']);
<a name="l00081"></a>00081                                 $dbConn-&gt;PConnect($dsConf['field_host']['vDEF'], $dsConf['field_username']['vDEF'], $dsConf['field_password']['vDEF'], $dsConf['field_dbname']['vDEF']);
<a name="l00082"></a>00082                                 $dbConn-&gt;SetFetchMode(ADODB_FETCH_ASSOC);
<a name="l00083"></a>00083 
<a name="l00084"></a>00084                                 $content .= $dbConn-&gt;ErrorMsg();
<a name="l00085"></a>00085                                 <span class="keywordflow">if</span> ($dbConn-&gt;_connectionID) {
<a name="l00086"></a>00086                                         $content .= '&lt;/p&gt;';
<a name="l00087"></a>00087 
<a name="l00088"></a>00088                                         $query = 'SELECT * FROM '.$dsConf['field_table']['vDEF'];
<a name="l00089"></a>00089                                         $recordSet = &amp;$dbConn-&gt;SelectLimit ($query, 150);
<a name="l00090"></a>00090                                         <span class="keywordflow">if</span> (!$recordSet) {
<a name="l00091"></a>00091                                                 $content .= '&lt;p&gt;Query failed ('.htmlspecialchars($query).'):&lt;br /&gt;';
<a name="l00092"></a>00092                                                 $content .= $dbConn-&gt;ErrorMsg().'&lt;/p&gt;';
<a name="l00093"></a>00093                                         } <span class="keywordflow">else</span> {
<a name="l00094"></a>00094                                                 $content .= '&lt;span style=<span class="stringliteral">"color:green"</span>&gt;successful!&lt;/span&gt;&lt;/p&gt;';
<a name="l00095"></a>00095                                                 $counter = 0;
<a name="l00096"></a>00096                                                 $content .= '&lt;p&gt;Showing the first 150 entries from the result recordset:&lt;/p&gt;';
<a name="l00097"></a>00097                                                 $content .= '&lt;table border=<span class="stringliteral">"1"</span>&gt;';
<a name="l00098"></a>00098                                                 <span class="keywordflow">while</span> (!$recordSet-&gt;EOF) {
<a name="l00099"></a>00099                                                         $content .= '&lt;tr&gt;';
<a name="l00100"></a>00100                                                         <span class="keywordflow">if</span> ($counter == 0) {
<a name="l00101"></a>00101                                                                 foreach (array_keys($recordSet-&gt;fields) as $key) {
<a name="l00102"></a>00102                                                                         $content .= '&lt;th&gt;'.htmlspecialchars($key).'&lt;/th&gt;';
<a name="l00103"></a>00103                                                                 }
<a name="l00104"></a>00104                                                                 $content .= '&lt;/tr&gt;&lt;tr&gt;';
<a name="l00105"></a>00105                                                         }
<a name="l00106"></a>00106                                                         foreach (array_values($recordSet-&gt;fields) as $value) {
<a name="l00107"></a>00107                                                                 $content .= '&lt;td&gt;'.htmlspecialchars($value).'&amp;nbsp;&lt;/td&gt;';
<a name="l00108"></a>00108                                                         }
<a name="l00109"></a>00109                                                         $recordSet-&gt;MoveNext();
<a name="l00110"></a>00110                                                         $counter++;
<a name="l00111"></a>00111                                                         $content .= '&lt;/tr&gt;';
<a name="l00112"></a>00112                                                 }
<a name="l00113"></a>00113                                                 $content .= '&lt;table&gt;';
<a name="l00114"></a>00114                                         }
<a name="l00115"></a>00115                                 }
<a name="l00116"></a>00116                         } <span class="keywordflow">else</span> {
<a name="l00117"></a>00117                                 $content .= '&lt;span style=<span class="stringliteral">"color:red"</span>&gt;failed!&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Error Message:&lt;/strong&gt;'. $dbConn-&gt;ErrorMsg().'&lt;/p&gt;';
<a name="l00118"></a>00118                         }
<a name="l00119"></a>00119                 }
<a name="l00120"></a>00120 
<a name="l00121"></a>00121                 $content .= '&lt;/body&gt;&lt;/html&gt;';
<a name="l00122"></a>00122                 echo ($content);
<a name="l00123"></a>00123         }
<a name="l00124"></a>00124 
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126 
<a name="l00127"></a>00127         <span class="comment">// Make instance:</span>
<a name="l00128"></a>00128 $SOBE = <a class="code" href="classt3lib__div.html#b47f8a8e8be44b79a0b8064dcd427bc1">t3lib_div::makeInstance</a>('<a class="code" href="classtx__adodb__checkconnectionwizard.html">tx_adodb_checkconnectionwizard</a>');
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 $SOBE-&gt;main();
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 ?&gt;
</pre></div><?php
  include_once '../doc-typo3-funcs.php';
  get_footer();
?>