summaryrefslogtreecommitdiff
path: root/demos/sqlmap/protected/pages/Manual/CodingExamples.page
blob: bbd1488ef14b28f22e2ac131f44c2881ec622d28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<com:TContent ID="body">
<h1>Cookbook sample</h1>

<h2>Executing Update (insert, update, delete)</h2>
<com:TTextHighlighter Language="php" CssClass="source">
$product = new Product();
$product->setId(1);
$product->setDescription('Shih Tzui');

$key = $sqlMap->insert('insertProduct', $product);
</com:TTextHighlighter>

<h2>Executing Query for Object (select)</h2>
<com:TTextHighlighter Language="php" CssClass="source">
$key = 1;
$product = $sqlMap->queryForObject ('getProduct', $key);
</com:TTextHighlighter>


<h2>Executing Query for Object (select) With Preallocated Result Object</h2>
<com:TTextHighlighter Language="php" CssClass="source">
$customer = new Customer();

$sqlMap->beginTransaction();

$sqlMap->queryForObject('getCust', $parameter, $customer);
$sqlMap->queryForObject('getAddr', $parameter, $customer);
$sqlMap->commitTransaction();
</com:TTextHighlighter>

<h2>Executing Query for List (select)</h2>
<com:TTextHighlighter Language="php" CssClass="source">
$list = $sqlMap->queryForList ('getProductList');
</com:TTextHighlighter>

<h2>Executing Query for List (select) With Result Boundaries</h2>
<com:TTextHighlighter Language="php" CssClass="source">
$list = $sqlMap->queryForList ('getProductList', $key, null, 0, 40);
</com:TTextHighlighter>

<h2>Executing Query for Paginated List (select)</h2>
<com:TTextHighlighter Language="php" CssClass="source">
$list = $sqlMap->queryForPagedList ('getProductList', null, 10);
$list->nextPage();
$list->previousPage();
</com:TTextHighlighter>

<h2>Executing Query for Map</h2>
<com:TTextHighlighter Language="php" CssClass="source">
 $map = $sqlMap->QueryForMap('getProductList', null, 'productCode');
 $product = $map['EST-93'];
</com:TTextHighlighter>


</com:TContent>