|
|
| version 1.33, 2004/03/23 09:43:44 | version 1.35, 2004/03/25 11:51:19 |
|---|---|
| Line 1 | Line 1 |
| @main2[] | @auto[] |
| ^switch[2]{ | $request:charset[windows-1251] |
| ^case(1){one} | $response:charset[windows-1251] |
| ^case[DEFAULT]{def} | |
| @main[] | |
| $table[^table::create{pet | |
| cat milk}] | |
| $hash[^table.hash[pet]] | |
| ^display[$hash] | |
| @main[] | |
| ^connect[mysql://root@localhost/paf]{ | |
| $hash[^hash::sql{select 'cat' as pet | |
| #, 'milk' as food | |
| }] | |
| ^display_hash[$hash] | |
| } | } |
| @main[] | |
| ^connect[mysql://root@localhost/paf]{ | |
| $participants[^hash::sql{select 'feodor' as participant }] | |
| } | |
| @get[] | #:даст хеш такой структуры: |
| $result[ | $participantsZ[ |
| $._default{^math:random(10)} | $.alex(1) |
| $.boris(1) | |
| ] | ] |
| #end @getBasketData[] | |
| #:из которого можно эффективно извлекать информацию, например, так: | |
| $person[feodor] | |
| $person ^if($participants.$person){участвует}{не участвует} в мероприятии | |
| } | |
| @display_hash[hash] | |
| #$hash.a.a | |
| ^hash.foreach[k;v]{hash $k=( | |
| ^if($v is hash){^display_hash[$v]}{ | |
| ^if($v is bool){bool ^if($v){true;false}}{string $v} | |
| } | |
| }[,] | |
| )^#0A}] | |
| @main[] | @main[] |
| $h[^get[]] | $name[ Вася ] |
| "$name" | |
| "^name.trim[]" | |
| =$h.1= | |
| $path[/section/subsection/] | |
| ^path.trim[end;/] | |
| @main[] | |
| $xdoc[^xdoc::create{<?xml version="1.0"?> | |
| <document xmlns:s="urn:special"> | |
| <s:code>string</s:code> | |
| </document> | |
| }] | |
| $xdoc.search-namespaces.s[urn:special] | |
| ^xdoc.selectString[string(//s:code)] |