(PHP)CRUDÀ༰·ÖÒ³Àà
֮ǰдµÄcrudÀàʵÔڱȽϼòµ¥£¨http://blog.csdn.net/yycai/archive/2009/12/15/5012353.aspx£©£¬ÖØзâ×°ÁËһϣº
<?php
/**
* ×Ô¶¯»¯Êý¾Ý±í²Ù×÷Àà
* @example
* <code>
* $db = cls_crud::factory(array('table'=>'article'));
* $data = $db->get_block_list(array('category_id' => 3), 9);
*
* $data = $db->get_list(array('title', 'id', 'time'), array('category_id'=>$cid), 'time', 1, $_GET['page'], 2, 1);
* $page_html = $db->page->get_html("?action=list&cid={$cid}", 'ylmf-page');
*
* </code>
* @author С²Ì <cyy0523xc@gmail.com>
* @version 1.2
*/
class cls_crud
{
private static $_instance = null;
/**
* Êý¾Ý±íÃû
* @var string
*/
private $table = '';
private $link;
private $query_id;
/**
* ·ÖÒ³¶ÔÏó
* @var array
*/
public $page = null;
/**
* ˽Óй¹Ô캯Êý£¨µ¥Àýģʽ£©
* @param
*/
private function __construct()
{
}
/**
* ÅäÖÃ
* @param array $config ÅäÖñäÁ¿
*/
private function config($config)
{
if(!empty($config))
{
foreach($config as $cf => $val)
{
$this->$cf = $val;
}
}
}
/**
* ¹¤³§º¯Êý
* @param array $config ÅäÖñäÁ¿£¨×î»ù±¾ÒªÅäÖÃÊý¾Ý±íÃû£©
* @param array $database Êý¾Ý¿âÁ´½Ó²ÎÊý
*/
public static function factory($config, $database=array())
{
if (null === self::$_instance)
{
self::$_instance = new self();
self::$_instance->connect($database);
self::$_instance->page = new cls_page();
}
self::$_instance->config($config);
return self::$_instance;
}
/**
* ÉèÖÃÊý¾Ý±í(ÀýÈ磺ÔÚ²Ù×÷µÄ¹ý³ÌÖÐÐèÒª¸Ä±äÊý¾Ý±í£¬¾Í¿ÉÒÔʹÓô˷½·¨)
* @param string $table
*/
public function set_table($table)
{
$this->table =
Ïà¹ØÎĵµ£º
ÕâÊÇһЩʹÓÃƵÂʱȽϸߵĺ¯Êý£¬ÓеÄÀ´×Ô±ðÈ˵ijÌÐò......
1.²úÉúËæ»ú×Ö·û´®º¯Êý
function random($length) {
$hash = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($ ......
½ñÌì»Ø¹ËÁËÏÂÕýÔòµÄ»ù±¾ÖªÊ¶¡£ ×ÜÈÝÒ×Íü£¬ÌؼÇÓÚ´Ë¡£
ÓÃÓÚÃèÊö×Ö·ûÅÅÁкÍÆ¥ÅäģʽµÄÒ»ÖÖÓï·¨¹æÔò¡£ËüÖ÷ÒªÓÃÓÚ×Ö·û´®µÄģʽ·Ö¸î¡¢Æ¥Åä¡¢²éÕÒ¼°Ìæ»»²Ù×÷¡£
PHPÖеÄÕýÔòº¯Êý£º
PHPÖÐÓÐÁ½Ì×ÕýÔòº¯Êý£¬Á½Õß¹¦Äܲ¶à£¬·Ö±ðΪ£º
Ò»Ì×ÊÇÓÉPCRE£¨Perl Compatible Regular Expression£©¿âÌṩµÄ¡£Ê¹ÓÓpreg_” ......
»ù±¾¸ÅÄî
Ò»¸öÕýÔò±í´ïʽͨ³£±»³ÆΪһ¸öģʽ (pattern)£¬ÎªÓÃÀ´ÃèÊö»òÕßÆ¥ÅäһϵÁзûºÏij¸ö¾ä·¨¹æÔòµÄ×Ö·û´®¡£ÀýÈ磺Handel¡¢Händel ºÍ Haendel ÕâÈý¸ö×Ö·û´®£¬¶¼¿ÉÒÔÓÉ“H(a|ä|ae)ndel”Õâ¸öģʽÀ´ÃèÊö¡£´ó²¿·ÖÕýÔò±í´ïʽµÄÐÎʽ¶¼ÓÐÈçϵĽṹ£º
Ñ¡Ôñ| ÊúÖ±·Ö¸ô·û´ú±íÑ¡Ôñ¡£ÀýÈç“gray|grey&rd ......
Memcache::add — Ìí¼ÓÒ»¸öÖµ£¬Èç¹ûÒѾ´æÔÚ£¬Ôò·µ»Øfalse
Memcache::addServer — Ìí¼ÓÒ»¸ö¿É¹©Ê¹ÓõķþÎñÆ÷µØÖ·
Memcache::close — ¹Ø±ÕÒ»¸öMemcache¶ÔÏó
Memcache::connect — ´´½¨Ò»¸öMemcache¶ÔÏó
memcache_debug — ¿ØÖƵ÷ÊÔ¹¦ÄÜ
Memcache::decrement — ¶Ô±£´æµÄij¸ökeyÖеÄÖµ½ ......
function checkFileType($fileName){
$file = fopen($fileName, "rb");
$bin = fread($file, 2); //Ö»¶Á2×Ö½Ú
&n ......