Texty - Very Simple MYSQL like, flatfile database

Started on the old forum in July 2011 · view the original in the archive · old links redirect here

2 replies · 1,641 views · started 15 years ago · 1 min read

2 participants
i0nutzxp Developer · 150 posts #1

Mysql like flat file database system. Version: Alfa2

Declaration:

require('Texty/texty.php');
$db = texty_connect(); //or $texty->connect();

Create table:

texty_create_table('photos#name,link'); // or $texty->create_table('');

Insert a new row:

$statement = "INSERT IN photos SET name=%, link=% WHERE unique=Name";
$texty->query($statement, 'Name', 'google.com');

Update row: [PHP $statement = "UPDATE users SET age=%, town=% WHERE unique=Max";
//or $statement = "UPDATE users SET age=%, town=%";
$texty->query($statement, 35, 'L.A');

Select users

$query = $texty->query("SELECT * FROM users");
while ($row = texty_fetch_assoc($query))
  echo 'Name = '.$row['name'].'<br/>';

Delete from:

$texty->query("DELETE FROM users"); // delete all users
$texty->query("DELETE FROM users WHERE unique=test"); // delete unique = x user

Debug:

 $texty->error(); // or texty_error();

Free result:

$texty->free_result(); // texty_free_result();

All methods of Texty class have a function eg: $texty->password(); and texty_password(); except $texty->query();

This versios has some bugfixes and some rewritten facilities.

In the next version: (coming next days)

  • Database indexes: eg: $texty->query("SELECT * FROM users WHERE age=%s", 22);
  • Prepared statements
  • maybe a panel for managing the databases
  • bug fixes

I want your feedback!

Thx in advance.

<?php unlink('World/Europe/Romania.country'); ?>
Attachments: Texty.rar
mobidev Senior · 312 posts #2

i0nutzxp wrote: I wanted to make a simple database system using text files. Name: Texty Version: ALFA Syntax: like mysql

Samples: Declaration:

<?php
   require('Texty/texty.php'); // db lib
   
  $database = $texty->connect(); //default database
  //OR
 //$database = $texty->connect('db2'); //create: db2 database
?>

Create table:

<?php
   require('Texty/texty.php'); // db lib
   
  $database = $texty->connect();
  $texty->create_table("users#name,age,town", $database);
  // users - table name
  // fields separated by , : field1,field2
  // $database - conexion id
?>

Insert row:

<?php
   require('Texty/texty.php'); // db lib
   
  $database = $texty->connect();
  $statement = "INSERT IN users SET name=%, age=%, town=% WHERE unique=Max";
  $texty->query($statement, 'Max', 21, 'New York');
  // texty::query(statement, param1, param 2, ...., param n);
  // where % from statement means param : something like printf function
?>

UPDATE ROW

<?php
   require('Texty/texty.php'); // db lib
   
  $database = $texty->connect();
  $statement = "UPDATE users SET age=%, town=% WHERE unique=Max";
  $texty->query($statement, 35, 'L.A');
  // texty::query(statement, param1, param 2, ...., param n);
  // where % from statement means param : something like printf function
  // known bug: minimum 2 % in statement
?>

SELECT

<?php
   require('Texty/texty.php'); // db lib
   
  $database = $texty->connect();
  $texty->query("SELECT * FROM users");
  // or query("SELECT name FROM users");
  // or query("SELECT name, town FROM users");
  // or query("SELECT * FROM users WHERE unique=Max");

 // use foreach instead of while on data printing
 foreach ($texty->fetch_object() AS $info)
 {
    echo 'Name: '.$info->name.'<br/>';
    echo 'Age: '.$info->age.'<br/>';
    echo 'Town: '.$info->town.'<br/><br/>';
 }
 foreach ($texty->fetch_assoc() AS $info)
 {
    echo 'Name: '.$info['name'].'<br/>';
    echo 'Age: '.$info['age'].'<br/>';
    echo 'Town: '.$info['town'].'<br/><br/>';
 }
?>

This system is tested only on local. When i'll have time i'll update this lib.

Next Features:

  1. DELETE - query("DELETE FROM table");
  2. ADD indexs
  3. Script optimization
  4. More features

Pleas post your sugestions and bugs.

thanks i was actually pondering on a flatfile db for a project i was thinking about and seeing ur layout might just work perfect for me

i0nutzxp Developer · 150 posts #3

New version released.

<?php unlink('World/Europe/Romania.country'); ?>

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close