/** * createFromParams() * Constructor for the THINKER_Object_Column Class that creates objects from the provided values * * @access public * @static * @param $schemaName: Schema Name * @param $tableName: Table Name * @param $columnName: Column Name * @param $defaultValue: Column Default Value * @param $nullable: Column Allows Nulls * @param $dataType: Short Data Type Definition * @param $fullType: Full Data Type Definition * @param $maxLength: Max Length of Column * @param $columnComment: Column Comment * @return THINKER_Object_Column Object */ public static function createFromParams($schemaName, $tableName, $columnName, $defaultValue, $nullable, $dataType, $fullType, $maxLength, $columnComment) { $Object = new THINKER_Object_Column(); // Set values $Object->setColumnSchema($schemaName); $Object->setColumnTable($tableName); $Object->setColumnName($columnName); $Object->setColumnDefaultValue($defaultValue); $Object->setNullable($nullable); $Object->setColumnType($dataType); $Object->setColumnFullType($fullType); $Object->setColumnMaxLength($maxLength); $Object->setColumnComment($columnComment); return $Object; }
/** * dataSelect() * Passes data back for the 'dataSelect' subsection * * @access public */ public function dataSelect() { // Check for schema information $Schema = $this->session->__get('PRIMARY_SCHEMA'); $Table = $this->session->__get('PRIMARY_TABLE'); if (!empty($Schema) && !empty($Table)) { $this->set('schemaName', $Schema->getSchemaName()); $this->set('tableName', $Table->getTableFriendlyName()); // Get the tables to reference $Tables = array(); $Tables[] = array('TABLE' => $Table, 'COLUMNS' => THINKER_Object_Table::getTableColumnNames($Schema->getSchemaName(), $Table->getTableName()), 'RELATIONSHIP' => null); // Discover relationships $Relationships = $Table->discoverRelationships(); if ($Relationships) { // Compile columns from relationship tables foreach ($Relationships as $T) { $Tables[] = array('TABLE' => THINKER_Object_Table::createFromDB($T->getReferencedSchema(), $T->getReferencedTable()), 'COLUMNS' => THINKER_Object_Table::getTableColumnNames($T->getReferencedSchema(), $T->getReferencedTable()), 'RELATIONSHIP' => $T); } } // Now perform any actions specified, since we can use the columns to pull the selected fields $phase = getPageVar('phase', 'str', 'GET'); switch ($phase) { case 'noCols': pushMessage('Invalid or no columns selected!', 'warning'); break; case 'proceed': // Gather all possible column selections // For each column, create the expected ID string and try to grab its value $selectCols = array(); foreach ($Tables as $t) { $ColTable = $t['TABLE']; $cols = $t['COLUMNS']; $ColRelationship = $t['RELATIONSHIP']; // Loop through cols foreach ($cols as $col) { list($colName, $colFriendlyName) = $col; $srcRelationCol = null; if (!empty($ColRelationship)) { $srcRelationCol = $ColRelationship->getSourceColumn(); } $id = $this->createColId($ColTable->getTableSchema(), $ColTable->getTableName(), $colName, $srcRelationCol); // Pull data $val = getPageVar($id, 'checkbox', 'POST', false); if ($val) { // Add to list of columns to pull $selectCols[$id] = array('TABLE' => $ColTable, 'COLUMN' => THINKER_Object_Column::createFromDB($ColTable->getTableSchema(), $ColTable->getTableName(), $colName), 'RELATIONSHIP' => $ColRelationship); } } } if (!empty($selectCols)) { // Add to session and redirect $this->session->__set('PULL_COLUMNS', $selectCols); redirect('DataPull', 'filterSelect'); } else { // Try again redirect('DataPull', 'dataSelect', array('phase' => 'noCols')); } break; } $this->set('tables', $Tables); } else { // Redirect back to database selection redirect('DataPull', 'dbSelect', array('phase' => 'invalidCombo')); } return true; }