PHP Classes

Storage Class: Manipulate data in arrays and store it in files

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 182 All time: 8,697 This week: 455Up
Version License PHP version Categories
storage-class 0.1BSD License5.3PHP 5, Databases, Files and Folders
Description 

Author

This package can manipulate data in arrays and store it in files.

It can take data in arrays and perform manipulation operations like databases such as searching, joining array records, ordering the results and return them split in pages of limited number of records.

The records of array data may be loaded and stored in files.

Picture of Peter
  Performance   Level  
Name: Peter <contact>
Classes: 4 packages by
Country: Taiwan Taiwan
Age: 40
All time rank: 16425 in Taiwan Taiwan
Week rank: 164 Up1 in Taiwan Taiwan Up

Example

<?php
include_once('../config/config_setting.php');
$config = config_setting::get_config();
$main_path = $config['main_path'];
include_once(
"{$main_path}/index.php");

cross_storage_join();

function
cross_storage_join() {

   
$begin = microtime();

   
//crate object and load library
   
$storage = new index();
   
$storage->load('join');
   
$storage->load('order');
   
$storage->load('database');
   
$storage->load('mmcache');

   
//check permission data from memcache
   
$permission = $storage->mmcache->get('permission');

    if(
TRUE === empty($permission)) { //no permission data in memcache

        //check user data from memcache
       
$mysql = $storage->mmcache->get('user');

        if(
TRUE === empty($mysql)) { //no user data in memcache
           
$sql = "SELECT * FROM user";
           
$mysql = $storage->database->read_database($sql);

           
//write into memcache
           
$storage->mmcache->set_expire(3600);
           
$storage->mmcache->add('user', $mysql);
            echo
"user data from database <br />\n";
        }
        else {
            echo
"user data from memcache <br />\n";
        }

       
//check group data from memcache
       
$pgsql = $storage->mmcache->get('group');

        if(
TRUE === empty($pgsql)) { //no group data in memcache
           
$use = 'pgsql';
           
$host = '127.0.0.1';
           
$user = 'test';
           
$password = '12345678';
           
$database = 'test';
           
$storage->database->add_server($use, $host, $user, $password, $database);
           
$sql = "SELECT * FROM ugroup";
           
$pgsql = $storage->database->query($sql);
           
$pgsql = $pgsql->fetchAll(PDO::FETCH_ASSOC);

           
//write into memcache
           
$storage->mmcache->set_expire(3600);
           
$storage->mmcache->add('group', $pgsql);
            echo
"group data from database <br />\n";
        }
        else {
            echo
"group data from memcache <br />\n";
        }

       
$table_name = array('user' => 'group');
       
$storage->join->set_table_name($table_name);
       
$bind = array('group_id' => 'id');
       
$permission = $storage->join->inner_join($mysql, $pgsql, $bind);

       
//write into memcache
       
$storage->mmcache->set_expire(3600);
       
$storage->mmcache->add('permission', $permission);
        echo
"permission data from database <br />\n";
    }
    else {
        echo
"permission data from memcache <br />\n";
    }

    echo
"<br />\n";

   
//sort permission data
   
$orderBy = array('user.id' => 'ASC', 'user.account' => 'ASC');
   
$storage->order->order($permission, $orderBy);

   
print_r($permission);

    echo
"<br /><br />\n";

    echo
'Use ' . (microtime() - $begin) . ' microseconds';
}


Details

Storage

?????????????????????????Join??????????????

????????????PDO????????????????????????????????SQL??

[??]

1.??????????inner join, left join, right join, outer join, full join?

2.?????????????SQL?order by??

3.?????????????????

4.??????????

5.????????????????????

6.?????????memcache

7.?????????????????????????????????????????????????event page

8.??????????????????

[?????]

base - ???????

cache - ??????????

config - ???????

test - ????????????????

index.php - ???

[????]

?????test?????????????

[About author]

Name : Peter Cheng

Country : Taiwan

EMail 1 : teed7334@gmail.com

EMail 2 : teed7334@163.com


  Files folder image Files (53)  
File Role Description
Files folder imagebase (9 files)
Files folder imagecache (1 file)
Files folder imageconfig (4 files)
Files folder imagelibrary (1 directory)
Files folder imagetest (3 files, 9 directories)
Plain text file index.php Class Class source
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files (53)  /  base  
File Role Description
  Plain text file database.php Class Class source
  Plain text file file.php Class Class source
  Plain text file find.php Class Class source
  Plain text file images.php Class Class source
  Plain text file join.php Class Class source
  Plain text file mmcache.php Class Class source
  Plain text file order.php Class Class source
  Plain text file paging.php Class Class source
  Plain text file render.php Class Class source

  Files folder image Files (53)  /  cache  
File Role Description
  Accessible without login Plain text file index.php Data Auxiliary data

  Files folder image Files (53)  /  config  
File Role Description
  Accessible without login Plain text file config_database.php Conf. Configuration script
  Plain text file config_images.php Class Class source
  Accessible without login Plain text file config_memcache.php Conf. Configuration script
  Accessible without login Plain text file config_setting.php Conf. Configuration script

  Files folder image Files (53)  /  library  
File Role Description
Files folder imagesimplehtmldom (2 files, 1 directory)

  Files folder image Files (53)  /  library  /  simplehtmldom  
File Role Description
Files folder imageapp (2 files, 1 directory)
  Accessible without login Plain text file change_log.txt Doc. Documentation
  Plain text file simple_html_dom.php Class Class source

  Files folder image Files (53)  /  library  /  simplehtmldom  /  app  
File Role Description
Files folder imagejs (4 files, 1 directory)
  Accessible without login HTML file google.htm Doc. Documentation
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files (53)  /  library  /  simplehtmldom  /  app  /  js  
File Role Description
Files folder imageimages (2 files)
  Accessible without login Plain text file jquery.js Data Auxiliary data
  Accessible without login Plain text file jquery.treeview.css Data Auxiliary data
  Accessible without login Plain text file jquery.treeview.js Data Auxiliary data
  Accessible without login Plain text file screen.css Data Auxiliary data

  Files folder image Files (53)  /  library  /  simplehtmldom  /  app  /  js  /  images  
File Role Description
  Accessible without login Image file treeview-default-line.gif Data Auxiliary data
  Accessible without login Image file treeview-default.gif Icon Icon image

  Files folder image Files (53)  /  test  
File Role Description
Files folder imagedatabase (5 files)
Files folder imagefile (1 file)
Files folder imagefind (2 files)
Files folder imageimages (3 files)
Files folder imagejoin (6 files)
Files folder imagemmcache (4 files)
Files folder imageorder (1 file)
Files folder imagepaging (1 file)
Files folder imagerender (1 file)
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file mysql_example.sql Data Auxiliary data
  Accessible without login Plain text file pgsql_example.sql Data Auxiliary data

  Files folder image Files (53)  /  test  /  database  
File Role Description
  Accessible without login Plain text file add.php Example Example script
  Accessible without login Plain text file delete.php Example Example script
  Accessible without login Plain text file example.sql Data Auxiliary data
  Accessible without login Plain text file get.php Example Example script
  Accessible without login Plain text file set.php Example Example script

  Files folder image Files (53)  /  test  /  file  
File Role Description
  Accessible without login Plain text file file.php Example Example script

  Files folder image Files (53)  /  test  /  find  
File Role Description
  Accessible without login Plain text file full_text_search.php Example Example script
  Accessible without login Plain text file search.php Example Example script

  Files folder image Files (53)  /  test  /  images  
File Role Description
  Accessible without login Image file blackberries.jpg Data Auxiliary data
  Accessible without login Plain text file resize.php Example Example script
  Accessible without login Plain text file slice.php Example Example script

  Files folder image Files (53)  /  test  /  join  
File Role Description
  Accessible without login Plain text file cross_join.php Example Example script
  Accessible without login Plain text file full_join.php Example Example script
  Accessible without login Plain text file inner_join.php Example Example script
  Accessible without login Plain text file left_join.php Example Example script
  Accessible without login Plain text file natural_join.php Example Example script
  Accessible without login Plain text file right_join.php Example Example script

  Files folder image Files (53)  /  test  /  mmcache  
File Role Description
  Accessible without login Plain text file add.php Example Example script
  Accessible without login Plain text file delete.php Example Example script
  Accessible without login Plain text file get.php Example Example script
  Accessible without login Plain text file set.php Example Example script

  Files folder image Files (53)  /  test  /  order  
File Role Description
  Accessible without login Plain text file order.php Example Example script

  Files folder image Files (53)  /  test  /  paging  
File Role Description
  Accessible without login Plain text file page.php Example Example script

  Files folder image Files (53)  /  test  /  render  
File Role Description
  Accessible without login Plain text file render.php Example Example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:182
This week:0
All time:8,697
This week:455Up