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 Êý¾ÝÊý×é
Ïà¹ØÎĵµ£º
string date ( string format [, int timestamp] ) //ÆäÖÐtimestampΪ¿ÉÑ¡£¬Ä¬ÈÏֵΪtime();
date("1"); //Monday
date("m.d.y"); //12.21.09
date("m.d.Y");//12.21.2009
$tomorrow = mktime(0, 0, 0, date("m") , date("d")+1, date("Y"));
$las ......
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
¼ÓÈëÒÔϼ¸ÐУº ......
1£¬¶¨Òåheader()Í·²¿Êä³ö¸ñʽ
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:finlename=php.xls");
vnd.ms-excel -----¶¨ÒåÊä³öÎļþ¸ñ
php.xls ---------¶¨ÒåÊä³öµÄÎļþÃû
2£¬Êä³ö±à ......
function checkFileType($fileName){
$file = fopen($fileName, "rb");
$bin = fread($file, 2); //Ö»¶Á2×Ö½Ú
&n ......