PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Mihajlo Siljanoski   PHP JSON File Database   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP JSON File Database
Create and manipulate databases using JSON files
Author: By
Last change: Update of example.php
Date: 1 year ago
Size: 1,126 bytes
 

Contents

Class file image Download
<?php

//Example of use

require_once 'lib/filedb.php';

$db=new filedb('testdatabase');


//if you like to drop database and all tables
//$db->drop_database();

//if you like to drop user table
$db->drop_table('user');


//if you like to create user table
$db->create_table('user');



//if you like to add record in user table if table user doesn't exist automaticaly will be created
$db->insert('user',['name'=>'Mihajlo','surname'=>'Siljanoski','web'=>'http://1mk.org/','username'=>'admin','password'=>md5('admin')]);



//to update record in user table
$db->update(
       
'user',
        [
'surname'=>'Siljanoski updated','web'=>false,'address'=>'Test address'],//address will be added and web will be deleted
       
['_id'=>1,'name%'=>'mihajlo'] // where ID =1 AND name LIKE '%mihajlo%'
);


//to delete record with _id=5
$db->delete(
       
'user',
        [
'_id'=>5]
);


//fetch records from database something like SELECT * FROM users WHERE name='Mihajlo' AND surname LIKE '%ski%'
$results=$db->get('user',
        [
           
'name'=>'Mihajlo',
           
'surname%'=>'ski',
        ]
    );
print_r($results);