From: konrad Date: Sun, 10 Jan 2010 13:08:56 +0000 (+0000) Subject: *processor: make determination of table null/notnull more logical X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=d92e158f988f8850f2350acb685c74a321260b10;p=web%2Fkonrad%2Fsmoke.git *processor: make determination of table null/notnull more logical *php: make db-retrievals more resilient *qt: translated right names git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@411 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/woc/phpout.cpp b/woc/phpout.cpp index 0a0adb9..5ccb84b 100644 --- a/woc/phpout.cpp +++ b/woc/phpout.cpp @@ -162,18 +162,23 @@ void WocPHPServerOut::newTable(const WocTable&tbl) //static get instance QStringList cols=tbl.columns(); QStringList pcols=tbl.primaryColumns(); + //header code+="public static function getFromDB("; for(int i=0;idbInst(); + //DB query code+="){\n\tglobal "+dbi+";\n\t$res="+dbi+"->select(\""+tbl.name()+"\",\"*\",\""; for(int i=0;iescapeColumn(\""+tbl.name()+"\",\""+pcols[i]+"\",$"+pcols[i]+").\""; } - code+="\");\n\tif($res!==false && count($res)<1)return false;\n\telse return new WT"+tbl.name()+"($res[0],true);\n}\n\n"; + code+="\");\n"; + //check result + code+="\tif($res===false)return false;\n\tif(count($res)<1)return false;\n\telse return new WT"+tbl.name()+"($res[0],true);\n}\n\n"; + //static get selection code+="public static function selectFromDB($where=\"\",$orderby=\"\"){\n\tglobal "+dbi+";\n\t$res="+dbi+"->select(\""+tbl.name()+"\",\"*\",$where,$orderby);\n\tif($res===false || count($res)<1)return array();\n\t"; code+="$r=array();\n\tforeach($res as $row)\n\t\t$r[]=new WT"+tbl.name()+"($row,true);\n\treturn $r;\n}\n\n"; @@ -715,6 +720,7 @@ QString WocPHPServerOut::classMappings(const WocClass&cls) WocTable tab=WocProcessor::instance()->table(k[i]); //single object mapping code+="\nstatic public function fromTable"+k[i]+"($table){\n"; + code+="\tif($table === false)return false;\n"; code+="\t$data=new WO"+cls.name()+"();\n"; QMapmap=cls.mapping(k[i]); QStringList mapk=cls.mappingProperties(k[i]); diff --git a/woc/processor.cpp b/woc/processor.cpp index 279a93c..8da690c 100644 --- a/woc/processor.cpp +++ b/woc/processor.cpp @@ -773,9 +773,11 @@ QPair WocTable::parseColumn(const QDomElement&el,QString m cl.isprime=str2bool(el.attribute("primarykey","0")); cl.isunique=str2bool(el.attribute("unique","0")); cl.isindex=str2bool(el.attribute("index","0")); + if(cl.isprime)cl.isnull=false; + else cl.isnull=true; if(el.hasAttribute("null")) cl.isnull=str2bool(el.attribute("null")); - else + else if(el.hasAttribute("notnull")) cl.isnull=!str2bool(el.attribute("notnull","0")); cl.type=el.attribute("type"); //TODO: validate type diff --git a/woc/qtout.cpp b/woc/qtout.cpp index beb2e85..3762836 100644 --- a/woc/qtout.cpp +++ b/woc/qtout.cpp @@ -737,6 +737,7 @@ void WocQtClientOut::trnList() code+=",\n P"+pp[i].replace(':',"_"); code+="\n };\n"; code+=" static QString rightToString(Right);\n"; + code+=" static QString rightToLocalString(Right);\n"; code+=" static Right stringToRight(QString);\n"; code+=" static QStringList allKnownRightsString();\n"; code+=" static QList allKnownRights();\n"; @@ -748,6 +749,12 @@ void WocQtClientOut::trnList() for(int i=0;i