コード例 #1
0
 public function finish()
 {
     $colsDef = array();
     $colsDef[] = "`id` INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT";
     foreach ($this->_columns as $column) {
         $expanded = Connection::expandColumn($column['type'], $column['options']);
         $colsDef[] = sprintf("`%s` %s", $column['name'], $expanded);
     }
     $colsDef[] = "PRIMARY KEY (`id`)";
     $sql = array();
     $sql[] = sprintf("CREATE TABLE `%s` (", $this->_tableName);
     $sql[] = implode(",\n", $colsDef);
     $sql[] = sprintf(") ENGINE %s;", $this->_options['engine']);
     $sql = implode("\n", $sql);
     $datasource = ConnectionManager::getDataSource();
     $datasource->execute($sql);
 }
コード例 #2
0
ファイル: Gen.php プロジェクト: radius/roxphp
	protected function _generateViews($name) {
		$tableName = Inflector::tableize($name);
		$datasource = ConnectionManager::getDataSource();
		$attributes = $datasource->generateAttributeMapFromTable($tableName);

		$templates = array('add', 'edit', 'index', 'view');

		$vars = array(
			'attributes' => $attributes,
			'friendlyModelName' => Inflector::humanize(Inflector::classify($name)),
			'modelVarName' => Inflector::lowerCamelize(Inflector::classify(Inflector::singularize($name))),
			'pluralModelVarName' => Inflector::lowerCamelize(Inflector::pluralize($name)),
			'controller' => Inflector::tableize($name)
		);

		foreach ($templates as $template) {	
			$data = $this->_renderTemplate("views/{$template}", $vars, true);	
			$folder = Inflector::tableize($name);
			$this->_writeFile("/views/{$folder}/{$template}.html.tpl", $data);
		}
	}
コード例 #3
0
ファイル: Views.php プロジェクト: raymondjavaxx/roxphp
 public function generate($name, $colDefs = array())
 {
     if (empty($colDefs)) {
         $tableName = Inflector::tableize($name);
         $datasource = ConnectionManager::getDataSource();
         $attributes = $datasource->generateAttributeMapFromTable($tableName);
     } else {
         $columns = Migration::parseColumnDefinitions($colDefs);
         $names = array_map(function ($col) {
             return $col['name'];
         }, $columns);
         $types = array_map(function ($col) {
             return $col['type'];
         }, $columns);
         $attributes = array_combine($names, $types);
     }
     $templates = array('add', 'edit', 'index', 'view');
     $vars = array('attributes' => $attributes, 'friendlyModelName' => Inflector::humanize(Inflector::classify($name)), 'modelVarName' => Inflector::lowerCamelize(Inflector::classify(Inflector::singularize($name))), 'pluralModelVarName' => Inflector::lowerCamelize(Inflector::pluralize($name)), 'controller' => Inflector::tableize($name));
     foreach ($templates as $template) {
         $data = $this->_renderTemplate("views/{$template}", $vars, true);
         $folder = Inflector::tableize($name);
         $this->_writeFile("/views/{$folder}/{$template}.html.tpl", $data);
     }
 }
コード例 #4
0
ファイル: ActiveRecord.php プロジェクト: radius/roxphp
	/**
	 * undocumented function
	 *
	 * @return \rox\DataSource
	 */
	public static function datasource() {
		return ConnectionManager::getDataSource(static::$_dataSourceName);
	}
コード例 #5
0
ファイル: Migrator.php プロジェクト: raymondjavaxx/roxphp
 protected static function _flagAsMigrated($version, $direction)
 {
     $datasource = ConnectionManager::getDataSource();
     if ($direction == 'up') {
         $sql = "INSERT INTO `schema_migrations`(`version`) VALUES('{$version}')";
         $datasource->execute($sql);
     } else {
         $sql = "DELETE FROM `schema_migrations` WHERE `version` = '{$version}'";
         $datasource->execute($sql);
     }
 }
コード例 #6
0
ファイル: Connection.php プロジェクト: raymondjavaxx/roxphp
 protected function _datasource()
 {
     return ConnectionManager::getDataSource();
 }