Question
How to have a query text field, and have the result processed in a module. I only want to enter a keyword, and in my own module a lookup is done in SQLite. The result is displayed in TWiki. Thus basically a search in an own DB. It seems to me a function ought to exist, but can't locate it.
Environment
--
TonTLam - 26 Apr 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
You might want to investigate
DatabasePlugin
--
CrawfordCurrie - 26 Apr 2006
Or the more extensive
DBIQueryPlugin. See also
Tag:database
.
--
PeterThoeny - 27 Apr 2006
Thanks for the pointers. On its own it is very easy to read a SQLite DB from TWiki.
use DBI;
$db = "<path>/phonelist";
$dbh = DBI->connect("dbi:SQLite:dbname=$db")
or die "couldn't connect to database: " . DBI->errstr;
$query = "select * from phone";
and so on ...
I should rephrase my question:
How to have a text field query, to specify a search condition
in. From there press [GO], and the search is done, and displayed. Thus like in the
WebSearch.
I assume it will be something liek this in my own TWiki module
$_[0] =~ s/%PHONE%/&TextQueryPhone("tag")/e;
This causes an text query input field. Via the
tag I read the value. And that is passed to some SQL statement. How to get this back in the module ? Likewise the %COMMENT%. I did check the code, but wasn't able to discover what really is going on.
--
TonTLam - 27 Apr 2006
You can pass URL parameters into your custom variable, such as:
%PHONE{ name="%URLPARAM{name}" }%. Basically like the
WebSearch topic.
In the Plugin, you can parse the value and pass that along to your subroutine. Read existing Plugin code to see how to parse the parameters. See example in
TagMePlugin code with
TWiki::Func::extractNameValuePair().
--
PeterThoeny - 27 Apr 2006