function default_Disp($field_value = "") { if (!$this->getRData('hidden')) { $dbc = $this->getDbCon(); //$dbc = $GLOBALS['conx']; list($tablename, $fielduniqid, $fielddisplay, $defaultvalue, $query) = explode(":", $this->getRData('radiobutton')); $qFieldDisplay = new SqlQuery($dbc); $qFieldDisplay->query("select {$fielduniqid}, {$fielddisplay} from {$tablename} where {$fielduniqid}='" . $field_value . "'"); $avfielddisplay = $qFieldDisplay->fetchArray(); $fval = ""; for ($i = 1; $i < count($avfielddisplay); $i++) { $fval .= $avfielddisplay[$i] . " "; } // $fval=$vfielddisplay; $fval = substr($fval, 0, strlen($fval) - 2); $qFieldDisplay->free(); $this->processed .= $this->no_PhpCode($fval); } }
function default_Form($field_value = "") { if (!$this->getRData("hidden")) { //global $conx; //$query = new sqlQuery($conx); $tableName = "auditlog"; $columnName = "application"; $sql = "SHOW COLUMNS FROM {$tableName} LIKE '{$columnName}'"; $query = new SqlQuery($this->getDbConn()); $query->query($sql); $row = $query->fetchArray(); $enum = explode("','", preg_replace("/(enum|set)\\('(.+?)'\\)/", "\\2", $row["Type"])); $fval = "<select name=\"fields[" . $this->getFieldName() . "]\">"; for ($i = 0; $i < sizeof($applications); $i++) { $fval .= "<option value=\"" . $applications[$i] . "\">" . $applications[$i] . "</option>"; } $fval .= "</select>"; $this->processed .= $fval; } }
/** * __call magic method to generate DataObject or load data in the object. * * This is where the magic happened. * * Those magic methods display saved view, form or saved query as well a manage relations. * ->get_name_of_saved_query will load and run an SQLfusion from the savedquery/ folder. * ->view_name_of_a_serialized_report will load and display a view from the report/ folder. * ->form_name_of_a_serialized_form will load and display a form from the form/ folder. * Relation: * ->GetChildNameOfChildDataObject ($BlogEntries->GetChildComments()) will return an instance of * the child object with a dataset containing only the child entries of the current Object value. * An example is at: http://radria.sqlfusion.com/documentation/core:by_example_php5#relations * ->GetParent... works the same why but look on the Parent relation and will return one record. * * @param method name of the method called * @param params array of parameters used on the method call. */ public function __call($method, $params) { try { $this->setLog("\n DataObject __call for method:" . $method); if (method_exists($this, $method)) { return; } $method_found = false; // lets use the method as an ordering. if (ereg("^getChild(.*)\$", $method, $match)) { $this->setLog("\n DataObject __call for child:" . $match[1]); $tablename = strtolower($match[1]); $order_limit = $params[0]; $class_name = $match[1]; $this->setLog("\n DataObject:" . $tablename . " Doesn exist checking if the table exists"); $q_tables = new sqlQuery($this->getDbCon()); $q_tables->getTables(); $table_found = false; if (class_exists($class_name)) { $this->setLog("\n DataObject:" . $class_name . " exist instanciating it with child values"); $new_data_object = new $class_name($this->getDbCon()); if (strlen($new_data_object->getTable()) > 0) { $tablename = $new_data_object->getTable(); } $new_data_object->{$this->getPrimaryKey()} = $this->getPrimaryKeyValue(); $new_data_object->query("select * from " . $tablename . " where " . $this->getPrimaryKey() . "=" . $this->getPrimaryKeyValue() . " " . $order_limit); $method_found = true; return $new_data_object; } else { $this->setLog("\n DataObject:" . $class_name . " Doesn't exist checking if the table " . $tablename . " exists"); while ($tables = $q_tables->fetchArray()) { if ($tablename == $tables[0]) { $table_found = true; } } if ($table_found) { $this->setLog("\nDataObject Table Found creating new data object:" . $tablename); $new_data_object = new DataObject($this->getDbCon()); $new_data_object->setTable($tablename); $new_data_object->setPrimaryKey("id" . $tablename); $new_data_object->{$this->getPrimaryKey()} = $this->getData($this->getPrimaryKey()); $new_data_object->query("select * from " . $tablename . " where " . $this->getPrimaryKey() . "=" . $this->getData($this->getPrimaryKey())); $method_found = true; //$this->{$tablename} = $new_data_object; return $new_data_object; } else { throw new RadriaException("Table:" . $tablename . " Not Found Could not create an Object"); } } } if (ereg("^getParent(.*)\$", $method, $match)) { $this->setLog("\n DataObject __call for parent:" . $match[1]); $tablename = strtolower($match[1]); if (class_exists($tablename) && is_subclass_of($tablename, "DataObject")) { $this->setLog("\n DataObject class for" . $tablename . " exists will instanciate it"); $do = new $tablename($this->getDbCon()); //$do->query("select * from ".$tablename." where ".$do->getPrimaryKey()."=".$this->getData($do->getPrimaryKey())); $do->getId($this->{$do->getPrimaryKey()}); $method_found = true; return $do; } else { $this->setLog("\n DataObject class for " . $tablename . " Doesn exist checking if the table exists"); $q_tables = new SqlQuery($this->getDbCon()); $q_tables->getTables(); $table_found = false; while ($tables = $q_tables->fetchArray()) { if ($tablename == $tables[0]) { $table_found = true; } } if ($table_found) { $this->setLog("\n Creating new data object:" . $tablename); $new_data_object = new DataObject($this->getDbCon()); $new_data_object->setTable($tablename); $new_data_object->setPrimaryKey("id" . $tablename); $new_data_object->query("select * from " . $tablename . " where " . $new_data_object->getPrimaryKey() . "=" . $this->getData($new_data_object->getPrimaryKey())); $method_found = true; //$this->{$tablename} = $new_data_object; return $new_data_object; } else { throw new RadriaException("Table:" . $tablename . " Not Found"); } } } if (!$method_found) { // throw new RadriaException("Method:" . $method . " Not Found"); die("Method:" . $method . " Not Found"); } return false; } catch (RadriaException $e) { $this->setError("\n DataObject Exception: " . $e->getMessage()); throw new RadriaException($e->getMessage() . " when calling method:" . $method); } catch (\Exception $e) { trigger_error("Method" . $method . " Not found", E_USER_ERROR); } }