Date: 10/03/00
- Next message: ssilk: "[phplib-dev] cvs commit"
- Next in thread: ssilk: "[phplib-dev] cvs commit"
- Maybe reply: ssilk: "[phplib-dev] cvs commit"
- Reply: Alexander Aulbach: "Re: [phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: ssilk
Date: Wed Oct 4 03:39:03 2000
Added files:
php-lib/php/tree_sql.inc
Log message:
This class will manage a SQL-Tree for you.
IT IS TESTED FOR PHP4 ONLY! (and will most probably not work with PHP3)
It is thought for small (1000-10000 elements) trees, which will not change
too often (it's a bad idea to use it for an discussion application for
example, but it's a good idea to use it for USENET-like represantations
of user-interrests).
The most famous advantage is, that every part of the tree can be
selected with a simple single select (SSS), no JOINS, no GROUP BY,
no nothing. So it is really FAST and SIMPLE.
The disadvantage is, that after every (or many linked) operation(s) on
the tree, the hole tree must be completly revisited (tree_revise())
and every element has to be updated (but see for what it is thought
above!). But the afford to revise the tree is only linear to the
number of elements in the tree.
For more informations currently read the source. I tried to document
it a little bit. Documentation will be available, when I have time.
It extends the class Query_Sql (which extends DB_Sql).
Example (it is really so short, I just removed the html-form):
<?php
.. includeallstuff ...
class bla_sql_tree extends tree_sql {
var $Host = "localhost";
var $Database = "test";
var $User = "test";
var $Password = "";
var $treetab = 'testtable';
var $t_pk = 'id';
var $t_path = 'path';
var $t_depth = 'depth';
var $t_ancestor='ancestor';
var $t_sort = 'tsort';
var $t_status= 'tstatus';
var $t_name = 'sname';
var $t_orderby ='sort,sname';
}
if (@$submit=="new") {
echo "INSERT NEW ELEMENT";
$tr->tree_insert($tr->capture_vars($tr->treetab));
} elseif (@$submit=="update") {
$p=$tr->t_pk;
echo "UPDATE ELEMENT ".($$p);
$tr->tree_update($tr->capture_vars($tr->treetab));
}
### provisional hack (Boezser Hack [tm])
$pk=@$pk;
$tr->query("SELECT * FROM $tr->treetab WHERE $tr->t_pk='$pk'");
$tr->next_record();
$r=$tr->Record;
?>
<html>
<body>
<table>
<tr valign=top><td>
<form action="<? echo $PHP_SELF ?>">
PK:<td> <? echo $r[$tr->t_pk] ?>
<input type="hidden" name="<? echo $tr->t_pk ?>" value="<? echo $r[$tr->t_pk] ?>
"><br>
the primary key
<tr valign=top><td>
ANCESTOR: <td><input name="ancestor" value="<? echo $r['ancestor']; ?>"><br>
Predecessor, which points to a PK
<tr valign=top><td>
SORT: <td><input name="sort" value="<? echo $r['sort']; ?>"><br>
The sorting of this element in this level
<tr valign=top><td>
Short: <td><input name="sname" value="<? echo $r['sname']; ?>"><br>
A unique name (should be lower-case, no spaces,)
<tr valign=top><td>
Name: <td><input name="name" value="<? echo $r['name']; ?>"><br>
The name
<tr valign=top><td>
Descr: <td><input name="descr" value="<? echo $r['descr']; ?>"><br>
Short Description
<tr valign=top><td>
Alternatives: <td><input name="alternames" value="<? echo $r['alternames'];
<br>
Helper for finding alternates. If Name=PKW,
then possible alternates would be "Autos, Fahrzeuge, Personenkraftwagen"
<tr valign=top><td colspan=2>
These fields will be generated automatic<br>
PATH: <? echo $r['path'] ?><br>
DEPTH: <? echo $r['depth'] ?><br>
TSORT: <? echo $r['tsort'] ?><br>
TSTATUS: <? echo $r['tstatus'] ?><br>
<tr><td>
<input type="submit" name="submit" VALUE="new">
<td>
<input type="submit" name="submit" VALUE="update">
</form>
</table>
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>
- Next message: ssilk: "[phplib-dev] cvs commit"
- Next in thread: ssilk: "[phplib-dev] cvs commit"
- Maybe reply: ssilk: "[phplib-dev] cvs commit"
- Reply: Alexander Aulbach: "Re: [phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

