当前位置: 首页>>代码示例>>PHP>>正文


PHP Schema::model方法代码示例

本文整理汇总了PHP中Schema::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Schema::model方法的具体用法?PHP Schema::model怎么用?PHP Schema::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Schema的用法示例。


在下文中一共展示了Schema::model方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     // Add ordering
     $criteria = new CDbCriteria();
     $criteria->order = "SCHEMA_NAME ASC";
     $schemata = Schema::model()->findAll($criteria);
     $dbSeperator = "_";
     $items = $root = $children = $items = array();
     foreach ($schemata as $schema) {
         // Find prefix in name
         if ($position = strpos($schema->SCHEMA_NAME, $dbSeperator)) {
             $prefix = substr($schema->SCHEMA_NAME, 0, $position);
             $root[$prefix] = $prefix;
             $children[$prefix][] = substr($schema->SCHEMA_NAME, $position + 1);
         } else {
             $root[] = $schema->SCHEMA_NAME;
         }
     }
     $i = 0;
     foreach ($root as $key => $item) {
         $childs = array();
         $childrenCount = count($children[$item]);
         if ($childrenCount > 1) {
             foreach ($children[$item] as $child) {
                 $childs[] = array('text' => CHtml::link($child, SchemaController::createUrl("/schema/" . $item . $dbSeperator . $child)));
             }
         } else {
             if ($childrenCount == 1) {
                 $name = $item . $dbSeperator . $children[$item][0];
             } else {
                 $name = $item;
             }
             $items[] = array('text' => CHtml::link($name, SchemaController::createUrl("/schema/" . $name)));
             $i++;
             continue;
         }
         $items[] = array('text' => $childrenCount == 0 ? CHtml::link($item, SchemaController::createUrl("/schema/" . $item)) : $item, 'expanded' => $i == 0 ? true : false, 'children' => $childs);
         $i++;
     }
     $this->data = $items;
     parent::init();
 }
开发者ID:cebe,项目名称:chive,代码行数:42,代码来源:SchemaTreeView.php

示例2: testDrop

 /**
  * Tests to drop a database.
  */
 public function testDrop()
 {
     // Load schema
     $schema = Schema::model()->findByPk('schematest2');
     // Drop
     $this->assertEquals(true, $schema->delete());
     // Load again
     $this->assertEquals(null, Schema::model()->findByPk('schematest2'));
 }
开发者ID:cebe,项目名称:chive,代码行数:12,代码来源:SchemaTest.php

示例3: loadSchema

 /**
  * Loads the current schema.
  *
  * @return	Schema
  */
 public function loadSchema()
 {
     if (is_null($this->_schema)) {
         $this->_schema = Schema::model()->findByPk($this->schema);
         if (is_null($this->_schema)) {
             throw new CHttpException(500, 'The requested schema does not exist.');
         }
     }
     return $this->_schema;
 }
开发者ID:cebe,项目名称:chive,代码行数:15,代码来源:SchemaController.php

示例4: runForm

 /**
  * Runs the form.
  */
 private function runForm()
 {
     // @todo: Load all exporters
     $exporterNames = array('SqlExporter', 'CsvExporter');
     // Instantiate supported exporters
     $this->exporters = array();
     foreach ($exporterNames as $exporter) {
         $supported = call_user_func(array($exporter, 'getSupportedModes'));
         if (in_array($this->mode, $supported)) {
             $this->exporters[] = new $exporter($this->mode);
         }
     }
     // Create the object list
     $this->objects = array();
     if ($this->mode == 'objects') {
         // Load schema
         $schema = Schema::model()->findByPk($this->schema);
         // Tables
         $tables = $schema->tables;
         if (count($tables) > 0) {
             $data = array();
             foreach ($tables as $table) {
                 $data['t:' . $table->TABLE_NAME] = $table->TABLE_NAME;
             }
             $this->objects[Yii::t('core', 'tables')] = $data;
         }
         // Views
         $views = $schema->views;
         if (count($views) > 0) {
             $data = array();
             foreach ($views as $view) {
                 $data['v:' . $view->TABLE_NAME] = $view->TABLE_NAME;
             }
             $this->objects[Yii::t('core', 'views')] = $data;
         }
         // Routines
         $routines = $schema->routines;
         if (count($routines) > 0) {
             $data = array();
             foreach ($routines as $routine) {
                 $data['r:' . $routine->ROUTINE_NAME] = $routine->ROUTINE_NAME;
             }
             $this->objects[Yii::t('core', 'routines')] = $data;
         }
     }
 }
开发者ID:cebe,项目名称:chive,代码行数:49,代码来源:ExportPage.php

示例5: actionCreateSchema

 public function actionCreateSchema()
 {
     $schema = new SchemaPrivilege();
     $schema->User = $this->user;
     $schema->Host = $this->host;
     if (isset($_POST['SchemaPrivilege'])) {
         $schema->attributes = $_POST['SchemaPrivilege'];
         if ($sql = $schema->save()) {
             $response = new AjaxResponse();
             $response->addNotification('success', Yii::t('core', 'successAddSchemaSpecificPrivileges', array('{user}' => $schema->User, '{host}' => $schema->Host, '{schema}' => $schema->Db)), null);
             $response->refresh = true;
             $this->sendJSON($response);
         }
     }
     // Prepare all schemata
     $schemata = $existing = array();
     $allSchemata = Schema::model()->findAll();
     $allExisting = SchemaPrivilege::model()->findAllByAttributes(array('User' => $this->user, 'Host' => $this->host));
     foreach ($allExisting as $existing1) {
         $existing[] = $existing1->Db;
     }
     foreach ($allSchemata as $schema1) {
         if (array_search($schema1->SCHEMA_NAME, $existing) === false) {
             $schemata[$schema1->SCHEMA_NAME] = $schema1->SCHEMA_NAME;
         }
     }
     $this->render('schemaPrivilegeForm', array('schema' => $schema, 'schemata' => $schemata));
 }
开发者ID:cebe,项目名称:chive,代码行数:28,代码来源:PrivilegesController.php


注:本文中的Schema::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。