PHPµÄCRUDÀà
ÒòΪÏîÄ¿ÐèÒª£¬ËùÒÔ×Ô¼ºÐ´ÁËÒ»¸öCRUDÀà
ËäÈ»»¹±È½Ï¼òµ¥£¬²»¹ý¸Ð¾õºÜʵÓá£
×¢£ºcls_databaseÊÇÒ»¸öÊý¾Ý¿â²Ù×÷Àà
¼û£ºhttp://code.google.com/p/cyy0523xc/source/browse/trunk/php/cls_crud.php
<?php
/**
* ×Ô¶¯»¯Êý¾Ý±í²Ù×÷Àà
* @author С²Ì <cyy0523xc@gmail.com>
* @version 1.0
*/
class cls_crud extends cls_database
{
/**
* Êý¾Ý±íÃû
* @var string
*/
private $table = '';
/**
* ¹¹Ô캯Êý
* @param array $config ÅäÖñäÁ¿
*/
public function __construct($config)
{
if(!empty($config))
{
foreach($config as $cf => $val)
{
$this->$cf = $val;
}
}
parent::__construct();
}
/**
* ÉèÖÃÊý¾Ý±í(ÀýÈ磺ÔÚ²Ù×÷µÄ¹ý³ÌÖÐÐèÒª¸Ä±äÊý¾Ý±í£¬¾Í¿ÉÒÔʹÓô˷½·¨)
* @param string $table
*/
public function set_table($table)
{
$this->table = $table;
}
/**
* ¶ÁÈ¡Ò»Ìõ¼Ç¼
* @param string $id Ö÷¼ü
* @param string $fields »ñÈ¡×Ö¶Î
* @return array
*/
public function read($id, $fields='*')
{
$sql = "SELECT {$fields} from `{$this->table}` WHERE `id`='{$id}'";
$this->query($sql);
return $this->fetch_one();
}
/**
* ²åÈëÒ»Ìõ¼Ç¼
* @param array $array Êý×é
* @return bool
*/
public function insert($array)
{
$fields = array();
$values = array();
foreach($array as $f => $v)
{
$fields[] = "`{$f}`";
$values[] = "'".mysql_real_escape_string($v)."'";
}
$fields = implode(',', $fields);
$values = implode(',', $values);
$sql = "INSERT INTO `{$this->table}`({$fields}) VALUES({$values})";
return $this->query($sql);
}
/**
* ¸üÐÂÒ»Ìõ¼Ç¼
* @param int $id Ö÷¼ü
* @param array $array Êý¾ÝÊý×é
Ïà¹ØÎĵµ£º
×Ô¼º±àд»ùÓÚMVCµÄÇáÁ¿¼¶PHP¿ò¼Ü
2008-4-3 23:33:56 Òѱ»ÔĶÁ£º
477 ·¢±íÆÀÂÛ
×öWEB¿ª·¢ÒÑÓÐÒ»Äê,ÿ´Î¶¼Ð´Öظ´µÄ¶«Î÷, Òò´Ë,Ïë×Ô¼ºÐ´Ò»Ï¿ò¼Ü,ÒԺ󿪷¢·½±ã.
±¾ÈË֮ǰѧϰasp.NETÁ½Äê,JSP°ëÄê,¿ÉÊǺóÀ´ÒòΪ¹¤×÷µÄԹʻ»³ÉPHP.ÆäʵºÜ²»Ï²»¶PHPµÄÓï·¨.»¹ÓÐPHPµÄº¯ÊýÃû,ÿ»Ø¶¼Íü¼Ç..»¹ÊÇϲ
»¶C#ºÍJAVAµÄÓï·¨,¹þ...²» ......
1.°Ñ½âѹµÄphp-5.2.6-Win32.zipÖØÃüÃûΪphp5¡£²¢¸´ÖƵ½DÅÌĿ¼Ï¡£¼´°²×°Â·¾¶Îª D:\php5
2.ÕÒµ½phpĿ¼Ï嵀 php.ini-dist»ò php.ini.recommendedÎļþ£¬ÖØÃüÃûΪ php.ini
3.ÔÙ°ÑphpĿ¼ÏµÄphp5ts.dll,libmysql.dll¸´ÖƵ½Ä¿Â¼ c:\windows\system32Ï¡£
4.°Ñphp5\extĿ¼ÏµÄphp_gd2.dll,php_mysql.dll,php_mbstring.dllÎ ......
1¡¢·Ö±ð°²×°Èý¸ö»·¾³£¬²¢ÉèÖò»Í¬¶Ë¿Ú
PHP:80
JSP:8080
ASP:8081
2¡¢ÉèÖÃ/Apache2/conf/httpd.conf
È¥µôÒÔÏÂÈýÐÐÇ°µÄ×¢ÊÍ£º
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
¼ÓÈëÒÔϼ¸ÐУº ......
ÒÔÏÂÊÇÀûÓÃphpʵÏÖÖÐÎÄˮӡµÄ´úÂë¡£
<?php
Header("Content-type: image/png"); /*֪ͨä¯ÀÀÆ÷,ÒªÊä³öͼÏñ*/
$im = imagecreate(400 , 300); /*¶¨ÒåͼÏñµÄ´óС*/
$gray = Ima ......
֮ǰдµÄ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), ......