Archive for 三月, 2009

一些开发中数据库的技巧

1、一般写多个表的时候,会把附表的内容生成数组缓存到主表上面去,这样查询的时候只查询一个表,附表中的内容用数组分解(只是小型的,大型的用lucene或solr,或底层用C来写)
2、搜索时,把搜索结果缓存到一个单独的表中,存结果ID,第二次搜索先求缓存表中的关键字
3、MYSQL < MYSQLi < PDO
4、文件缓存 < 内存缓存
5、数据的优化 < 业务层的优化

, , ,

No Comments

PHP中高级OOP的DEMO

PHP5.3
命名空间

<?php
//哎,为何非要用\了
namespace my\name; // see "Defining Namespaces" section
class MyClass {}
function myfunction() {}
const MYCONST = 1;

$a = new MyClass;
$c = new \my\name\MyClass; // see "Global Space" section
$a = strlen('hi'); // see "Using namespaces: fallback to global
// function/constant" section
$d = namespace\MYCONST; // see "namespace operator and __NAMESPACE__
// constant" section$d = __NAMESPACE__ . '\MYCONST';
echo constant($d); // see "Namespaces and dynamic language features" section
?>

Read the rest of this entry »

1 Comment