aboutsummaryrefslogtreecommitdiff
path: root/samples/malete.php
blob: 5935a838373b46e2d8545ce321194825db796324 (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
56
57
58
59
<?php
/**
 * Malete test script.
 */

// Import requisites.
require_once '../index.php';
require_once 'contrib/malete/php/Isis.php';

// Draw the document.
$display = new CinisisDisplayHelper('Malete Test');
	
// Create a db with field list ("fdt")
$fdt = array(
  'Test field 1' =>  1,
  'Test field 2' =>  2,
  'Test field 3' =>  3,
);

// Database connection setup.
$db  = 'dbname';
$db  = new Isis_Db($fdt, $db, new Isis_Server());

$display->h2('Server');

if (!$db->srv->sock) {
  echo "could not contact server\n";
}
else {
  $display->h3("Number of records");
  $query = 'Test';
  $recs  = $db->num_recs($query);
  echo "Got ". count($recs) ." terms for '$query'</br>\n";

  $display->h3("Terms beginning with...");
  $terms = $db->terms(strtoupper($query));
  echo "Got ". count($terms) ." terms for '$query'</br>\n";

  foreach ($terms as $t) {
    list($cnt, $term) = explode("\t", $t);
    echo "'$term'($cnt) \n";
  }

  $display->br();
  $display->h3('Query reading records');
  $recs = $db->query(strtoupper($query));

  echo "Got ". count($recs) ." records for '$query'</br>\n";

  foreach ($recs as $r) {
    $display->pre($r->toString());
  }

  $display->h3('Query reading a record');
  $r = $db->read(6);
  $display->pre($r->toString());
}

$display->footer();