| 1 |
lars |
1 |
<com:TContent ID="body">
|
|
|
2 |
<h1>Cookbook sample</h1>
|
|
|
3 |
|
|
|
4 |
<h2>Executing Update (insert, update, delete)</h2>
|
|
|
5 |
<com:TTextHighlighter Language="php" CssClass="source">
|
|
|
6 |
$product = new Product();
|
|
|
7 |
$product->setId(1);
|
|
|
8 |
$product->setDescription('Shih Tzui');
|
|
|
9 |
|
|
|
10 |
$key = $sqlMap->insert('insertProduct', $product);
|
|
|
11 |
</com:TTextHighlighter>
|
|
|
12 |
|
|
|
13 |
<h2>Executing Query for Object (select)</h2>
|
|
|
14 |
<com:TTextHighlighter Language="php" CssClass="source">
|
|
|
15 |
$key = 1;
|
|
|
16 |
$product = $sqlMap->queryForObject ('getProduct', $key);
|
|
|
17 |
</com:TTextHighlighter>
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
<h2>Executing Query for Object (select) With Preallocated Result Object</h2>
|
|
|
21 |
<com:TTextHighlighter Language="php" CssClass="source">
|
|
|
22 |
$customer = new Customer();
|
|
|
23 |
|
|
|
24 |
$sqlMap->beginTransaction();
|
|
|
25 |
|
|
|
26 |
$sqlMap->queryForObject('getCust', $parameter, $customer);
|
|
|
27 |
$sqlMap->queryForObject('getAddr', $parameter, $customer);
|
|
|
28 |
$sqlMap->commitTransaction();
|
|
|
29 |
</com:TTextHighlighter>
|
|
|
30 |
|
|
|
31 |
<h2>Executing Query for List (select)</h2>
|
|
|
32 |
<com:TTextHighlighter Language="php" CssClass="source">
|
|
|
33 |
$list = $sqlMap->queryForList ('getProductList');
|
|
|
34 |
</com:TTextHighlighter>
|
|
|
35 |
|
|
|
36 |
<h2>Executing Query for List (select) With Result Boundaries</h2>
|
|
|
37 |
<com:TTextHighlighter Language="php" CssClass="source">
|
|
|
38 |
$list = $sqlMap->queryForList ('getProductList', $key, null, 0, 40);
|
|
|
39 |
</com:TTextHighlighter>
|
|
|
40 |
|
|
|
41 |
<h2>Executing Query for Paginated List (select)</h2>
|
|
|
42 |
<com:TTextHighlighter Language="php" CssClass="source">
|
|
|
43 |
$list = $sqlMap->queryForPagedList ('getProductList', null, 10);
|
|
|
44 |
$list->nextPage();
|
|
|
45 |
$list->previousPage();
|
|
|
46 |
</com:TTextHighlighter>
|
|
|
47 |
|
|
|
48 |
<h2>Executing Query for Map</h2>
|
|
|
49 |
<com:TTextHighlighter Language="php" CssClass="source">
|
|
|
50 |
$map = $sqlMap->QueryForMap('getProductList', null, 'productCode');
|
|
|
51 |
$product = $map['EST-93'];
|
|
|
52 |
</com:TTextHighlighter>
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
</com:TContent>
|