Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 182 | | All time: 8,697 This week: 455 |
|
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. | |
|
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
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.