From 41da9b143b6e8b65b68c95415cfe302ad0a1ea9d Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 22 Feb 2010 16:59:56 -0300 Subject: Coding style --- query.php | 128 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 66 insertions(+), 62 deletions(-) diff --git a/query.php b/query.php index 4ac3b25..99e3895 100644 --- a/query.php +++ b/query.php @@ -1,84 +1,88 @@ - -// $Id: demo.php,v 1.3 2004/11/02 13:44:42 kripke Exp $ -// demo for the Isis package +Query -require 'malete/php/Isis.php'; // use require 'Isis/Rec.php' if you need only this -?> - Demo for package Isis - 22, 'b' => 42 - ) ); + // Get request parameters a and b + // (as well as any plain numeric and v%d style + $param = Isis_Http::fromReq(array( + 'a' => 22, + 'b' => 42, + )); - // create a db with field list ("fdt") - $fdt = array( - 'periodico' => 1, - 'data' => 2, - 'titulo' => 3, - ); + // Create a db with field list ("fdt") + $fdt = array( + 'Periodico' => 1, + 'Data' => 2, + 'Titulo' => 3, + 'Autor' => 4, + 'Assuntos primarios' => 5, + 'Assuntos secundarios' => 6, + 'Ilustrado' => 7, + 'Caderno' => 8, + 'Pagina' => 9, + 'Arquivo digital' => 10, + 'Forma documento' => 11, + 'Local de publicacao' => 12, + 'Observacoes' => 13, + 'Descritores imagem' => 14, + 'Termo geografico' => 16, + 'Coluna' => 17, + 'Recorte' => 19, + 'Alimentador' => 20, + 'Tema Anuario' => 21, + ); ?>

server

-srv->sock ) - echo "could not contact server\n"; - else { -?> -

terms beginning with...

terms($query); - echo "got ",count($terms), " terms for '$query'
\n"; - foreach ($terms as $t) { - list($cnt, $term) = explode("\t", $t); - echo "'$term'($cnt) "; - } - echo "
\n"; + $db = new Isis_Db($fdt, 'anu10', new Isis_Server()); + if (!$db->srv->sock) { + echo "could not contact server\n"; + } + else { ?> -

query reading records

+

terms beginning with...

+ query($query); - echo "got ",count($recs), " records for '$query'
\n"; - foreach ($recs as $r) - echo "
---\n", $r->toString(), "---\n
\n"; + $query = 'a'; + $terms = $db->terms($query); + echo "got ",count($terms), " terms for '$query'
\n"; + foreach ($terms as $t) { + list($cnt, $term) = explode("\t", $t); + echo "'$term'($cnt) "; + } + echo "
\n"; ?> -

query reading 1

+

query reading records

+ read(1); - echo "
---\n", $r->toString(), "---\n
\n"; + $query = 'Corumbiara'; + $recs = $db->query($query); + echo "got ",count($recs), " records for '$query'
\n"; + foreach ($recs as $r) { + echo "
---\n", $r->toString(), "---\n
\n"; + } ?> + +

query reading 1

+ read(1); + echo "
---\n", $r->toString(), "---\n
\n"; + } // end else could contact server ?> + -- cgit v1.2.3