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


PHP Column::model方法代码示例

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


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

示例1: categorySitemap

 /**
  * 分类
  */
 private function categorySitemap()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'classify=:category';
     $criteria->params = array(':category' => $this->classify);
     $criteria->limit = $this->limitPerPage;
     $criteria->offset = $this->pageStart;
     $result = Column::model()->findAll($criteria);
     foreach ($result as $k => $v) {
         $this->categoryItems[] = array('url' => $this->webSiteTitle . '/posts/col-' . $v->id . '.html', 'date' => date(DATE_W3C, time()));
     }
 }
开发者ID:ph7pal,项目名称:momo,代码行数:15,代码来源:Sitemap.php

示例2: loadTable

 /**
  * Loads the current table.
  *
  * @return	Table
  */
 public function loadTable()
 {
     if (is_null($this->_table)) {
         $pk = array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table);
         $this->_table = Table::model()->findByPk($pk);
         $this->_table->columns = Column::model()->findAllByAttributes($pk);
         if (is_null($this->_table)) {
             throw new CHttpException(500, 'The requested table does not exist.');
         }
     }
     return $this->_table;
 }
开发者ID:cebe,项目名称:chive,代码行数:17,代码来源:TableController.php

示例3: loadModel

	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 * @param integer the ID of the model to be loaded
	 */
	public function loadModel($id)
	{
		$model=Column::model()->findByPk((int)$id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
开发者ID:rualatngua,项目名称:Micro-Scrum,代码行数:12,代码来源:ColumnController.php

示例4: exportRowData

 /**
  * Exports all rows of the given array and writes the dump to the output buffer.
  *
  * @param	array					array with identifiers of rows
  */
 private function exportRowData()
 {
     $db = Yii::app()->db;
     $pdo = $db->getPdoInstance();
     // Columns
     $cols = Column::model()->findAllByAttributes(array('TABLE_NAME' => $this->table, 'TABLE_SCHEMA' => $this->schema));
     $blobCols = array();
     // Create insert statement
     if ($this->settings['completeInserts']) {
         $columns = array();
         $i = 0;
         foreach ($cols as $col) {
             $columns[] = $db->quoteColumnName($col->COLUMN_NAME);
             if (in_array(DataType::getBaseType($col->DATA_TYPE), array('smallblob', 'blob', 'mediumblob', 'longblob'))) {
                 $blobCols[] = $i;
             }
             $i++;
         }
         $columns = ' (' . implode(', ', $columns) . ')';
     } else {
         $columns = '';
     }
     $insert = $this->settings['insertCommand'] . ($this->settings['delayedInserts'] ? ' DELAYED' : '') . ($this->settings['ignoreInserts'] ? ' IGNORE' : '') . ' INTO ' . $db->quoteTableName($this->table) . $columns . ' VALUES';
     // Find all rows
     $rowCount = count($this->rows);
     // Settings
     $hexBlobs = $this->settings['hexBlobs'];
     $rowsPerInsert = (int) $this->settings['rowsPerInsert'];
     // Cycle rows
     $i = 0;
     $k = 1;
     foreach ($this->rows as $row) {
         // Add comment
         if ($i == 0) {
             $this->comment('Data for table ' . $db->quoteTableName($this->table));
             echo "\n\n";
             echo $insert;
         }
         $attributes = $row->getAttributes();
         SqlUtil::FixRow($attributes);
         // Escape all contents
         foreach ($attributes as $key => $value) {
             if ($value === null) {
                 $attributes[$key] = 'NULL';
             } elseif ($hexBlobs && in_array($key, $blobCols) && $value) {
                 $attributes[$key] = '0x' . bin2hex($value);
             } else {
                 $attributes[$key] = $pdo->quote($value);
             }
         }
         // Add this row
         echo "\n  (", implode(', ', $attributes), ')';
         if ($i == $rowCount - 1) {
             echo ";\n\n";
         } elseif ($k == $rowsPerInsert) {
             echo ";\n\n", $insert;
             $k = 0;
         } else {
             echo ',';
         }
         $i++;
         $k++;
     }
 }
开发者ID:cebe,项目名称:chive,代码行数:69,代码来源:SqlExporter.php

示例5: loadView

 /**
  * Loads the current view.
  *
  * @return	View
  */
 public function loadView()
 {
     if (is_null($this->_view)) {
         $pk = array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->view);
         $this->_view = View::model()->findByPk($pk);
         $this->_view->columns = Column::model()->findAllByAttributes($pk);
         if (is_null($this->_view)) {
             throw new CHttpException(500, 'The requested view does not exist.');
         }
     }
     return $this->_view;
 }
开发者ID:cebe,项目名称:chive,代码行数:17,代码来源:ViewController.php

示例6: exportRowData

 /**
  * Exports all rows of the given array and writes the dump to the output buffer.
  *
  * @param	array					array with identifiers of rows
  */
 private function exportRowData()
 {
     $db = Yii::app()->db;
     $pdo = $db->getPdoInstance();
     // Columns
     $cols = Column::model()->findAllByAttributes(array('TABLE_NAME' => $this->table, 'TABLE_SCHEMA' => $this->schema));
     $blobCols = array();
     $columns = array();
     $i = 0;
     foreach ($cols as $col) {
         $columns[] = $db->quoteColumnName($col->COLUMN_NAME);
         if (in_array(DataType::getBaseType($col->DATA_TYPE), array('smallblob', 'blob', 'mediumblob', 'longblob'))) {
             $blobCols[] = $i;
         }
         $i++;
     }
     $columns = implode($this->settings['fieldTerminator'], $columns);
     $insert = "";
     // Find all rows
     $rowCount = count($this->rows);
     // Settings
     $hexBlobs = $this->settings['hexBlobs'];
     $rowsPerInsert = (int) $this->settings['rowsPerInsert'];
     // Cycle rows
     $i = 0;
     $k = 1;
     foreach ($this->rows as $row) {
         if ($i == 0 && $this->settings['fieldsFirstRow']) {
             echo $columns;
         }
         $attributes = $row->getAttributes();
         SqlUtil::FixRow($attributes);
         // Escape all contents
         foreach ($attributes as $key => $value) {
             if ($value === null) {
                 $attributes[$key] = 'NULL';
             } elseif ($hexBlobs && in_array($key, $blobCols) && $value) {
                 $attributes[$key] = '0x' . bin2hex($value);
             } else {
                 $attributes[$key] = $this->settings['fieldEncloseString'] . addcslashes($value, $this->settings['fieldEncloseString']) . $this->settings['fieldEncloseString'];
             }
         }
         echo "\n", implode($this->settings['fieldTerminator'], $attributes);
         if ($i == $rowCount - 1) {
             echo "\n\n";
         }
         $i++;
         $k++;
     }
 }
开发者ID:cebe,项目名称:chive,代码行数:55,代码来源:CsvExporter.php

示例7: getOne

 public function getOne($keyid, $return = '')
 {
     if (!$keyid) {
         return false;
     }
     $item = Column::model()->findByPk($keyid);
     if ($return != '') {
         return $item[$return];
     }
     return $item;
 }
开发者ID:ph7pal,项目名称:wedding,代码行数:11,代码来源:Column.php

示例8: actionDrop

 public function actionDrop()
 {
     $columns = (array) $_POST['column'];
     $response = new AjaxResponse();
     $droppedColumns = $droppedSqls = array();
     foreach ($columns as $column) {
         $pk = array('TABLE_SCHEMA' => $this->schema, 'TABLE_NAME' => $this->table, 'COLUMN_NAME' => $column);
         $column = Column::model()->findByPk($pk);
         $column->throwExceptions = true;
         try {
             $sql = $column->delete();
             $droppedColumns[] = $column->COLUMN_NAME;
             $droppedSqls[] = $sql;
         } catch (DbException $ex) {
             $response->addNotification('error', Yii::t('core', 'errorDropColumn', array('{col}' => $column->COLUMN_NAME)), null, $ex->getText());
             $response->refresh = true;
         }
     }
     $count = count($droppedColumns);
     if ($count > 0) {
         $response->addNotification('success', Yii::t('core', 'successDropColumn', array($count, '{col}' => $droppedColumns[0], '{colCount}' => $count)), $count > 1 ? implode(', ', $droppedColumns) : null, implode("\n", $droppedSqls));
     }
     $this->sendJSON($response);
 }
开发者ID:cebe,项目名称:chive,代码行数:24,代码来源:ColumnController.php

示例9: testCreateTable

 /**
  * Test to create a Table
  */
 public function testCreateTable()
 {
     $col1 = new Column();
     $col1->COLUMN_NAME = 'test1';
     $col1->setDataType('int');
     $col1->setAutoIncrement(true);
     $col1->setIsNullable(false);
     $col1->size = 20;
     $col1->createPrimaryKey = true;
     $col2 = new Column();
     $col2->COLUMN_NAME = 'test2';
     $col2->setDataType('varchar');
     $col2->setCollation('utf8_general_ci');
     $col2->size = 250;
     $columns = array($col1, $col2);
     $table = new Table();
     // Set some properties and save
     $table->TABLE_NAME = 'innodb2';
     $table->TABLE_SCHEMA = 'tabletest';
     $table->optionChecksum = 1;
     $table->optionDelayKeyWrite = 1;
     $table->optionPackKeys = 0;
     $table->ENGINE = 'MyISAM';
     $table->TABLE_COLLATION = 'utf8_general_ci';
     $table->comment = 'mein testkommentar';
     $table->columns = $columns;
     $table->insert();
     $this->assertTrue(is_string($table->showCreateTable));
     $pk = array('TABLE_SCHEMA' => 'tabletest', 'TABLE_NAME' => 'innodb2', 'COLUMN_NAME' => 'test1');
     // Load column definition
     $col = Column::model()->findByPk($pk);
     $this->assertEquals('test1', $col->COLUMN_NAME);
     $this->assertEquals('int', $col->getDataType());
     $this->assertTrue($col->getAutoIncrement());
     $this->assertFalse($col->getIsNullable());
     $this->assertTrue($col->getIsPartOfPrimaryKey());
     $this->assertEquals(20, $col->size);
     $pk = array('TABLE_SCHEMA' => 'tabletest', 'TABLE_NAME' => 'innodb2', 'COLUMN_NAME' => 'test2');
     // Load column definition
     $col = Column::model()->findByPk($pk);
     $this->assertEquals('test2', $col->COLUMN_NAME);
     $this->assertEquals('varchar', $col->getDataType());
     $this->assertFalse($col->getAutoIncrement());
     $this->assertFalse($col->getIsNullable());
     $this->assertFalse($col->getIsPartOfPrimaryKey());
     $this->assertEquals('utf8_general_ci', $col->getCollation());
     $this->assertEquals(250, $col->size);
 }
开发者ID:cebe,项目名称:chive,代码行数:51,代码来源:TableTest.php

示例10: testInsertNotNew

 /**
  * Record can't be inserted cause its not new
  *
  * @expectedException CDbException
  */
 public function testInsertNotNew()
 {
     $pk = array('TABLE_SCHEMA' => 'columntest', 'TABLE_NAME' => 'test', 'COLUMN_NAME' => 'test5');
     // Load column definition
     $col = Column::model()->findByPk($pk);
     $col->insert();
 }
开发者ID:cebe,项目名称:chive,代码行数:12,代码来源:ColumnTest.php


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