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


PHP Column::save方法代码示例

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


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

示例1: actionCreate

 public function actionCreate()
 {
     $column = new Column();
     $column->TABLE_NAME = $this->table;
     $table = Table::model()->findByPk(array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table));
     if (isset($_POST['Column'])) {
         $column->attributes = $_POST['Column'];
         /*
          * Add index
          */
         $addIndices = array();
         if (isset($_POST['createIndexPrimary'])) {
             $column->createPrimaryKey = true;
         }
         if (isset($_POST['createIndex'])) {
             $addIndices['INDEX'] = $column->COLUMN_NAME;
         }
         if (isset($_POST['createIndexUnique'])) {
             $column->createUniqueKey = true;
         }
         if (isset($_POST['createIndexFulltext'])) {
             $addIndices['FULLTEXT'] = $column->COLUMN_NAME . (array_search($column->COLUMN_NAME, $addIndices) !== false ? '_fulltext' : '');
         }
         if ($sql = $column->save()) {
             $response = new AjaxResponse();
             $response->addNotification('success', Yii::t('core', 'successAddColumn', array('{col}' => $column->COLUMN_NAME)), null, $sql);
             $response->refresh = true;
             foreach ($addIndices as $type => $indexName) {
                 try {
                     $index = new Index();
                     $index->throwExceptions = true;
                     $index->TABLE_NAME = $this->table;
                     $index->TABLE_SCHEMA = $this->schema;
                     $index->INDEX_NAME = $indexName;
                     $index->setType($type);
                     $indexCol = new IndexColumn();
                     $indexCol->COLUMN_NAME = $column->COLUMN_NAME;
                     $index->columns = array($indexCol);
                     $sql = $index->save();
                     $response->addNotification('success', Yii::t('core', 'successCreateIndex', array('{index}' => $index->INDEX_NAME)), null, $sql);
                 } catch (DbException $ex) {
                     $response->addNotification('error', Yii::t('core', 'errorCreateIndex', array('{index}' => $index->INDEX_NAME)), $ex->getText(), $ex->getSql());
                 }
             }
             $this->sendJSON($response);
         }
     }
     $collations = Collation::model()->findAll(array('order' => 'COLLATION_NAME', 'select' => 'COLLATION_NAME, CHARACTER_SET_NAME AS collationGroup'));
     CHtml::generateRandomIdPrefix();
     $data = array('column' => $column, 'table' => $table, 'collations' => $collations);
     $data['formBody'] = $this->renderPartial('formBody', $data, true);
     $this->render('form', $data);
 }
开发者ID:cebe,项目名称:chive,代码行数:53,代码来源:ColumnController.php

示例2: actionCreate

	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new Column;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Column']))
		{
			$model->attributes=$_POST['Column'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->column_id));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
开发者ID:rualatngua,项目名称:Micro-Scrum,代码行数:22,代码来源:ColumnController.php

示例3: testInsert

 /**
  * tests to insert a new Column in to the Table
  */
 public function testInsert()
 {
     $col = new Column();
     $col->TABLE_SCHEMA = 'columntest';
     $col->TABLE_NAME = 'test';
     $col->COLUMN_NAME = 'testnew';
     $col->setDataType('DOUBLE');
     $col->COLUMN_DEFAULT = 1;
     $col->size = 20;
     $col->scale = 5;
     $col->setCollation('utf8_general_ci');
     $this->assertType('string', $col->save());
     // Load column definition
     $col = Column::model()->findByPk(array('TABLE_SCHEMA' => 'columntest', 'TABLE_NAME' => 'test', 'COLUMN_NAME' => 'testnew'));
     $this->assertEquals('double', $col->getDataType());
     $this->assertEquals(1.0, $col->COLUMN_DEFAULT);
     $this->assertNull($col->getCollation());
     $this->assertEquals(20, $col->size);
     $this->assertEquals(5, $col->scale);
 }
开发者ID:cebe,项目名称:chive,代码行数:23,代码来源:ColumnTest.php


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