def getFieldByCondition(self,aParam): ''' 根据条件查询内容 ''' resultRow = 1 if(aParam!=None): sSql = " SELECT %s FROM %s WHERE 1=1 AND %s " if( aParam.has_key(Config.HAS_JOIN) and aParam[Config.HAS_JOIN]!=""): sSql = " SELECT %s FROM %s " + aParam[Config.HAS_JOIN] +" WHERE 1=1 AND %s" condition = " AND 1=1 " SearchFields = " * " if( aParam.has_key(Config.S_SEARCHFIELDS) and aParam[Config.S_SEARCHFIELDS]!=""): SearchFields=aParam[Config.S_SEARCHFIELDS] if(aParam.has_key(Config.S_SEARCHCONDITION) and aParam[Config.S_SEARCHCONDITION]!=""): condition=aParam[Config.S_SEARCHCONDITION] if(aParam.has_key(Config.S_RESULTROW) and aParam[Config.S_RESULTROW]>1): resultRow=aParam[Config.S_RESULTROW] sSql = sSql % (SearchFields,aParam[Config.S_TABLE],condition) # Func.debugInfo(sSql) if(aParam.has_key(Config.S_ORDERBY) and aParam[Config.S_ORDERBY]!=""): sOrderBy = aParam[Config.S_ORDERBY] sSql = sSql+(" ORDER BY %s" % sOrderBy ) if(aParam.has_key(Config.S_LIMIT) and aParam[Config.S_LIMIT]!=""): sLimit = aParam[Config.S_LIMIT] else: sLimit = " 1 "; if(aParam.has_key(Config.S_FETCH_ALL) and aParam[Config.S_FETCH_ALL]==False): sSql = sSql + (" LIMIT %s"%sLimit) Func.debugInfo(sSql) if(resultRow>1): return self.findAll(sSql) else: return self.getOne(sSql) else: return None
def __init__(self): self.__pool = PooledDB(mysql.connector,mincached=0, maxcached=10, maxshared=10, maxusage=10000, **Func.getConfig("DbConnectString"))