public function main() { $aType = call_user_func([$this->typeName, 'getFieldsInfo']); $szIndex = call_user_func([$this->typeName, 'getIndexKey']); $sql = sprintf('select `%s`, `%s` as name, `%s` from `%s` where %s order by `%s` ', $szIndex, $this->fieldName, $this->fieldOrder, $aType['table'], $this->fieldCondition, $this->fieldOrder); $aData = \Extasy\ORM\DB::query($sql); foreach ($aData as $key => $value) { foreach ($value as $key2 => $value2) { $aData[$key][$key2] = str_replace("\n", '', $value2); } } print UParser::parsePHPFile(__DIR__ . DIRECTORY_SEPARATOR . 'order.tpl', array('szTitle' => $this->szTitle, 'aBegin' => $this->aBegin, 'type' => $this->typeName, 'back' => $this->back, 'aHidden' => $this->aHidden, 'aData' => $aData)); $this->output(); }
public function createDatabaseTable($dropTable = false) { $fields = static::getFieldsInfo(); if ($dropTable) { $sql = sprintf('DROP TABLE IF EXISTS `%s`', $fields['table']); DB::post($sql); } $queryBuilder = new \Extasy\ORM\QueryBuilder('create'); $queryBuilder->setTableName($fields['table']); foreach ($this->columns as $column) { $column->onCreateTable($queryBuilder); } $sql = $queryBuilder->prepare(); DB::post($sql); }
/** * @desc Вывод на обычной форме * @return */ function getFormValue() { $builder = new QueryBuilder('select'); $fieldsInfo = call_user_func(array($this->fieldInfo['model'], 'getFieldsInfo')); $nameField = isset($this->fieldInfo['cross_name']) ? $this->fieldInfo['cross_name'] : 'name'; $index = 'id'; $order = isset($fieldsInfo['order']) ? $fieldsInfo['order'] : 'id'; $builder->setSelect($index); $builder->setSelect($nameField); $builder->setFrom($fieldsInfo['table']); $builder->setOrderFunction($order); $data = \Extasy\ORM\DB::query($builder->prepare()); array_unshift($data, ['id' => 0, 'name' => 'Не выбрано']); $select = new CSelect(); $select->name = $this->szFieldName; $select->current = $this->aValue; $select->required = !empty($this->fieldInfo['required']) ? $this->fieldInfo['required'] : false; $select->values = $data; return $select->generate(); }
function getViewValue() { foreach (self::$aCache as $key => $row) { if ($row[0] == $this->fieldInfo['cross_table'] && $row[1] == $this->fieldInfo['cross_index'] && $row[2] == $this->aValue) { return $row[3]; } } $szNameField = $this->fieldInfo['cross_name']; $szIndex = $this->fieldInfo['cross_index']; $aResult = $this->loadAllRows(' `%s`= "%s"', DB::escape($szNameField), DB::escape($this->Value)); $szResult = !empty($aResult[0][$szNameField]) ? $aResult[0][$szNameField] : ''; self::$aCache[] = array($this->fieldInfo['cross_table'], $this->fieldInfo['cross_index'], $this->aValue, $szResult); return $szResult; }