[objective-c]EGODatabase #8 カラム名一覧取得

カラム名一覧取得

-(NSArray*)getColumnNamesByTableName:(NSString*)tableName{
    EGODatabase*db=[self getDB];
    NSString*sql=[NSString stringWithFormat:@"pragma table_info(%@)",tableName];
    EGODatabaseResult*result=[db executeQuery:sql];
    NSMutableArray*list=[NSMutableArray arrayWithCapacity:[result count]];
    for (EGODatabaseRow*row in result) {
        [list addObject:[row stringForColumn:@"name"]];
    }
    return [NSArray arrayWithArray:list];
}

[objective-c]EGODatabase #7 テーブル一覧取得

テーブル一覧取得

-(NSArray*)getTableNameList{
    EGODatabase*db=[self getDB];
    NSString*sql=@"select name from sqlite_master where type = 'table' order by name";
    EGODatabaseResult*result=[db executeQuery:sql];
    NSMutableArray*list=[NSMutableArray arrayWithCapacity:[result count]];
    for (EGODatabaseRow*row in result) {
        [list addObject:[row stringForColumn:@"name"]];
    }
    return [NSArray arrayWithArray:list];
}
-(EGODatabase*)getDB{
    EGODatabase* database = [EGODatabase databaseWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/database.db"]];
    return database;
}
-(BOOL)isExistTableByName:(NSString*)tableName{
    NSArray*tables=[self getTableNameList];
    return [tables containsObject:tableName];
}

[objective-c]ファイル存在確認

ファイル存在確認

//Documentsフォルダ内を確認
-(BOOL)isExistFile:(NSString*)fileName{
    NSString* path=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    path=[path stringByAppendingPathComponent:fileName];
    return [[NSFileManager defaultManager] fileExistsAtPath:path];
}
//fullパスで確認
-(BOOL)isExistFileByFullPath:(NSString*)path{
    return [[NSFileManager defaultManager] fileExistsAtPath:path];
}

[JavaScript]Fireworksコマンド - 選択したパスの塗りつぶし色を取得

選択したパスの塗りつぶし色を取得

var dom = fw.getDocumentDOM();
var r=0;
var le = fw.selection.length;
var d=new Array();
var str="";
var cols=[];
for (var m=0;m<le;m++){
	if(fw.selection[m]["pathAttributes"] && fw.selection[m]["pathAttributes"]["fillColor"]){
		var col=fw.selection[m].pathAttributes.fillColor;
		cols.push( {col:col, sort:getSortNum(col)} );
	}
}
cols=cols.sort(sortCol);
for(var m=0;m<cols.length;m++){
	if(m>0)str+=',';
	str+='"'+cols[m].col+'"';
}

var w=prompt('',str);

if(!w){
	cols=cols.reverse();
	str="";
	for(var m=0;m<cols.length;m++){
		if(m>0)str+=',';
		str+='"'+cols[m].col+'"';
	}

	var w=prompt('',str);
}
function sortCol(a,b){
	if(a.sort > b.sort)return 1;
	if(a.sort < b.sort)return -1;
	return 0;
}
function getSortNum(value){
	value=value.replace('#','');
	return Number('0x'+value);
}
function showInfo(obj){
	var str="";
	str+=obj;
	for(var key in obj){
		str+="\n";
		str+=key+" : "+obj[key];
	}
	alert(str);
}

[CakePHP 2.x]テーブルのカラム名を取得

テーブルのカラム名を取得

$this->Model->getColumnTypes();

Controller

$columnTypes=$this->SystemTest->getColumnTypes();
$columnNames=array_keys($columnTypes);
$this->set('columnTypes', $columnTypes);
$this->set('columnNames', $columnNames);

View

columnTypes<br/>
<?php
$tmp=var_export($columnTypes,true);
echo str_replace("\n", "<br/>", $tmp);
?>
<br/><br/>
columnNames<br/>
<?php
$tmp=var_export($columnNames,true);
echo str_replace("\n", "<br/>", $tmp);
?>

Sample