Example #1
0
 function Dataface_ViewRecord($viewname, $values = null)
 {
     if (is_a($viewname, 'Dataface_View')) {
         $this->view =& $viewname;
     } else {
         $this->view =& Dataface_View::loadView($viewname);
     }
     if (isset($values)) {
         $this->setValues($values);
     }
 }
Example #2
0
 /**
  * Guesses the name of the table from where the given field comes.
  */
 function guessColumnTableName($fieldname)
 {
     if (isset($this->_cache[__FUNCTION__][$fieldname])) {
         return $this->_cache[__FUNCTION__][$fieldname];
     }
     $data = $this->_parseSQL();
     $this->_expandGlobs($data);
     $numTables = count($data['tables']);
     for ($i = $numTables - 1; $i >= 0; $i--) {
         $curr = $data['tables'][$i];
         if ($curr['type'] == 'ident') {
             // This table is an actual table -- not a subselect
             $table =& Dataface_Table::loadTable($curr['value']);
             if ($table->hasField($fieldname)) {
                 if (@$curr['alias']) {
                     return $curr['alias'];
                 } else {
                     return $curr['value'];
                 }
             }
             unset($table);
         } else {
             if ($curr['type'] == 'subselect') {
                 // The table is a subselect
                 $subview = new Dataface_View($curr['value'], $curr['value']);
                 $field = $subview->getField($fieldname);
                 if (isset($field)) {
                     return $curr['value'];
                 }
                 unset($subview);
                 unset($field);
             } else {
                 trigger_error('Unspecified table type');
             }
         }
     }
 }