fix for pre-7.3 view wizard empty recordset bug from Bryan
authorchriskl <chriskl>
Mon, 24 May 2004 01:26:16 +0000 (01:26 +0000)
committerchriskl <chriskl>
Mon, 24 May 2004 01:26:16 +0000 (01:26 +0000)
classes/database/Postgres.php
views.php

index e493e3d91cea346dae3e7cc26b3705442d05e7be..abf7ca6773c005dff46d7b25c730547ed2b53a56 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.211 2004/05/23 15:55:04 chriskl Exp $
+ * $Id: Postgres.php,v 1.212 2004/05/24 01:26:16 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -3338,9 +3338,8 @@ class Postgres extends BaseDB {
         */
         function &getLinkingKeys($arrTables)
         {
-               // Pre 7.3 this does nothing
-               $recordset = new ADORecordSet;
-               return $recordset;
+               // Pre 7.3 this does nothing            
+               return false;
         }
        
        /**
index 74f491b3e7a12d41bfa16396eb2631b08e905a57..bf8fb1c844b7b2612735cc7a65974d2a27a970ed 100644 (file)
--- a/views.php
+++ b/views.php
@@ -3,7 +3,7 @@
        /**
         * Manage views in a database
         *
-        * $Id: views.php,v 1.34 2004/05/23 04:10:19 chriskl Exp $
+        * $Id: views.php,v 1.35 2004/05/24 01:26:16 chriskl Exp $
         */
 
        // Include application functions
                        
                        $rsLinkKeys = $data->getLinkingKeys($_POST['formTables']);
                        
-                       // Update tblcount if we have more foreign keys than tables (perhaps in the case of composite foreign keys)
-                       $linkCount = $rsLinkKeys->recordCount() > $tblCount ? $rsLinkKeys->recordCount() : $tblCount;
+                       // Update tblcount if we have more foreign keys than tables (perhaps in the case of composite foreign keys)  test if rsLinkKeys, because pre-7.3 it may be false and not a valid adodb recordset obj
+                       $linkCount = ($rsLinkKeys && ($rsLinkKeys->recordCount() > $tblCount) ) ? $rsLinkKeys->recordCount() : $tblCount;
                        
                        // Get fieldnames
                        for ($i = 0; $i < $tblCount; $i++) {                            
                        // Output selector for fields to be retrieved from view
                        echo GUI::printCombo($arrFields, 'formFields[]', false, '', true);                      
                        echo "</td>\n</tr>\n</table>\n<br />\n";                                                
-                       
-                       // Output the Linking keys combo boxes
-                       echo "<table>\n";
-                       echo "<tr><th class=\"data\">{$lang['strviewlink']}</th></tr>";                                 
-                       $rowClass = 'data1';
-                       for ($i = 0; $i < $linkCount; $i++) {
-                               // Initialise variables
-                               if (!isset($formLink[$i]['operator'])) $formLink[$i]['operator'] = 'INNER JOIN';
-                               echo "<tr>\n<td class=\"$rowClass\">\n";
-                                                       
-                               if (!$rsLinkKeys->EOF) {
-                                       $curLeftLink = htmlspecialchars("\"{$rsLinkKeys->f['p_table']}\".\"{$rsLinkKeys->f['p_field']}\"");
-                                       $curRightLink = htmlspecialchars("\"{$rsLinkKeys->f['f_table']}\".\"{$rsLinkKeys->f['f_field']}\"");
-                                       $rsLinkKeys->moveNext();
-                               }
-                               else {
-                                       $curLeftLink = '';
-                                       $curRightLink = '';
-                               }
+                                               
+                       if ($rsLinkKeys) {
+                               // Output the Linking keys combo boxes
+                               echo "<table>\n";
+                               echo "<tr><th class=\"data\">{$lang['strviewlink']}</th></tr>";                                 
+                               $rowClass = 'data1';
+                               for ($i = 0; $i < $linkCount; $i++) {
+                                       // Initialise variables
+                                       if (!isset($formLink[$i]['operator'])) $formLink[$i]['operator'] = 'INNER JOIN';
+                                       echo "<tr>\n<td class=\"$rowClass\">\n";
+                                                               
+                                       if (!$rsLinkKeys->EOF) {
+                                               $curLeftLink = htmlspecialchars("\"{$rsLinkKeys->f['p_table']}\".\"{$rsLinkKeys->f['p_field']}\"");
+                                               $curRightLink = htmlspecialchars("\"{$rsLinkKeys->f['f_table']}\".\"{$rsLinkKeys->f['f_field']}\"");
+                                               $rsLinkKeys->moveNext();
+                                       }
+                                       else {
+                                               $curLeftLink = '';
+                                               $curRightLink = '';
+                                       }
+                                       
+                                       echo GUI::printCombo($arrFields, "formLink[$i][leftlink]", true, $curLeftLink, false );
+                                       echo GUI::printCombo($data->joinOps, "formLink[$i][operator]", true, $formLink[$i]['operator']);
+                                       echo GUI::printCombo($arrFields, "formLink[$i][rightlink]", true, $curRightLink, false );
+                                       echo "</td>\n</tr>\n";
+                                       $rowClass = $rowClass == 'data1' ? 'data2' : 'data1';
                                
-                               echo GUI::printCombo($arrFields, "formLink[$i][leftlink]", true, $curLeftLink, false );
-                               echo GUI::printCombo($data->joinOps, "formLink[$i][operator]", true, $formLink[$i]['operator']);
-                               echo GUI::printCombo($arrFields, "formLink[$i][rightlink]", true, $curRightLink, false );
-                               echo "</td>\n</tr>\n";
-                               $rowClass = $rowClass == 'data1' ? 'data2' : 'data1';
-                       
-                       }
-                       echo "</table>\n<br />\n";                      
+                               }
+                               echo "</table>\n<br />\n";
+                       }                                               
                                                
                        // Output additional conditions                 
                        $arrOperators = array('=' => '=', 'LIKE' => 'LIKE', '!=' => '!=', '>' => '>', '<' =>'<', 'IN' => 'IN', '!!=' => '!!=', 'BETWEEN' => 'BETWEEN');