a simple relational database system
pjjTextBase is a set of powerful yet easy to use 20+ functions that provides a complete management for a simple relational database system, with data kept in industry standard text files (CSV, flat files).
This section shows some sample sample code.
Source : ➠ www.pjj.pl/pjjtextbase/
Note
$string will not convert to an $array.function ptb_select().$result = ''; should be changed to $result = array(); in file pjjtextbase.php at line 425.$result and a $sort is included, you get an error in function ptb_sort().if (is_array($result)) {
to :
if (count($result)) {
eregi is obsolete. The alternative is to use preg_match.$x = ptb_select($myDatabase, "eregi('text_to_look_for', 'author')");
use this :$x = ptb_select($myDatabase, "preg_match('/text_to_look_for/i', 'author')");
It will also work in PHP 5.This is the code to display the array below (for display purposes, some lines wrap. The ↵ character indicates it. The character is not part of the code) :
$path_to_db_script = $_SERVER['DOCUMENT_ROOT']↵
. "/" . "db/pjjtextbase.php";
require $path_to_db_script;
$novels = ptb_connect('novels.csv');
$hercule = ptb_select(
$novels,
"'@protagonist' == 1 AND 'year' == 1953",
'title ASC'
print_r ($hercule);
This is the output :
Array
(
[0] => Array
(
[id] => 43
[year] => 1953
[@protagonist] => 1
[title] => After the Funeral
[%aka] => 18
[protagonist] => Poirot, Hercule
[@nationality] => 1
[nationality] => Belgian
[aka] => Array
(
[0] => Funerals Are Fatal
)
)
)
And here is a record :
$theItem = 0;
echo $hercule[$theItem]["id"] . " - " . ↵
$hercule[$theItem]["protagonist"] . " - " . ↵
$hercule[$theItem]["title"];
43 - Poirot, Hercule - After the Funeral
⇪ Feb 17 2021 06:30:53