Новости | FAQ | Авторы | Документация | В действии | Библиотека |
Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
sergei v.2 08.07 09:46
@USE SqlCluster.p @main[] $oSqlApiMain[^SqlCluster::create[$oEnvConfig.database.api.main.1]] $t[^oSqlApiMain.table[SELECT id, name FROM public.news]] ^t.menu{ $t.id -- $t.name }[<br>] # не сработает через .R ---> $t[^oSqlApiMain.R.table[SELECT * FROM news]] # так же как и void (чтобы не делали void не с мастера) ^oSqlApiMain.R.void[DELETE FROM news WHERE id=-100] # через RW явно ---> $t[^oSqlApiMain.RW.table[SELECT * FROM news]] # через R ---> $t[^oSqlApiMain.table[SELECT * FROM news]] # через RW ---> ^oSqlApiMain.void[DELETE FROM news WHERE id=-100]
@CLASS SqlCluster ########################################################################### @create[hConnections;hParams][h;k;v;connect-string-rw;connect-string-r] $h[ ^if(def $hParams.bDebug){$.bDebug($hParams.bDebug)} ^if(def $hParams.bDebug){$.sCacheDir[$hParams.sCacheDir]} ] ^hConnections.servers.foreach[k;v]{ $connect-string-$k[^if(!def $hConnections.type || $hConnections.type eq mysql){mysql}{pgsql}://${hConnections.user}:${hConnections.password}@${v.host}^if(def $v.port){:$v.port}/${hConnections.db_name}^if(!def $hConnections.type || $hConnections.type eq mysql){?charset=utf8}] } $bDefR(false) ^if(!def $hConnections.type || $hConnections.type eq mysql){ $self.RW[^MySql::create[$connect-string-rw;$h]] ^if(def ${connect-string-r} && ${connect-string-r} ne ""){ $R[^MySql::create[$connect-string-r;$h]] $bDefR(true) } }{ $self.RW[^PgSql::create[$connect-string-rw;$h]] ^if(def ${connect-string-r} && ${connect-string-r} ne ""){ $R[^PgSql::create[$connect-string-r;$h]] $bDefR(true) } } ########################################################################### # some $hCacheOption are available: # $.bForce(1). force execute query without clearing file # $.sFile[path/to/cache-file]. path to file in $sCacheDir # $.bAuto(1|0). 1 - cache query with auto-generated filename, 0 - disable auto caching for query # $.dInterval(value). 0 - clear file and don't cache query [days, default=1] # $.dtExpirationTime[time when cache expire] # $.iThreshold(value). in any case file will be cleared after 1.5 * dInterval [%, default=100] ########################################################################### @void[jQuery;hSqlOption;hCacheOption] $result[^self.RW.void[$jQuery;$hSqlOption;$hCacheOption]] #end @void[] ########################################################################### @int[jQuery;hSqlOption;hCacheOption] $result[^if($bDefR){^R.int[$jQuery;$hSqlOption;$hCacheOption]}{^RW.int[$jQuery;$hSqlOption;$hCacheOption]}] #end @int[] ########################################################################### @double[jQuery;hSqlOption;hCacheOption] $result[^if($bDefR){^R.double[$jQuery;$hSqlOption;$hCacheOption]}{^RW.double[$jQuery;$hSqlOption;$hCacheOption]}] #end @double[] ########################################################################### @string[jQuery;hSqlOption;hCacheOption] $result[^if($bDefR){^R.string[$jQuery;$hSqlOption;$hCacheOption]}{^RW.string[$jQuery;$hSqlOption;$hCacheOption]}] #end @string[] ########################################################################### @table[jQuery;hSqlOption;hCacheOption] $result[^if($bDefR){^R.table[$jQuery;$hSqlOption;$hCacheOption]}{^RW.table[$jQuery;$hSqlOption;$hCacheOption]}] #end @table[] ########################################################################### @hash[jQuery;hSqlOption;hCacheOption] $result[^if($bDefR){^R.hash[$jQuery;$hSqlOption;$hCacheOption]}{^RW.hash[$jQuery;$hSqlOption;$hCacheOption]}] #end @hash[] ########################################################################### @file[jQuery;hSqlOption;hCacheOption] $result[^if($bDefR){^R.file[$jQuery;$hSqlOption;$hCacheOption]}{^RW.file[$jQuery;$hSqlOption;$hCacheOption]}] #end @file[]