岛国毛片,97人妻一区二区精品视频,日韩人妻中文字幕一区二区三区,午夜黄片特黄

中山php|最優(yōu)網(wǎng)絡中山做網(wǎng)站 中山php建站

最優(yōu)良人

2011/10/11 at 14:08

PHP預定義常量(內(nèi)部常量)DIRECTORY_SEPARATOR,PHP_VERSION,PHP_OS

DIRECTORY_SEPARATOR
是PHP內(nèi)部常量,表示路徑分隔符 在win里為\ ,在linux 里為/

PHP_VERSION
這個內(nèi)建常量是 PHP 程序的版本,如 '3.0.8-dev'。

PHP_OS
這個內(nèi)建常量指執(zhí)行 PHP 解析器的操作系統(tǒng)名稱,如 'Linux'。

預定義常量表

內(nèi)核預定義常量
這些常量在 PHP 的內(nèi)核中定義。它包含 PHP、Zend 引擎和 SAPI 模塊。

PHP_VERSION (string)
PHP_OS (string)
PHP_SAPI (string)
自 PHP 4.2.0 起可用。參見 php_sapi_name()。
PHP_EOL (string)
自 PHP 4.3.10 和 PHP 5.0.2 起可用
PHP_INT_MAX (integer)
自 PHP 4.4.0 和 PHP 5.0.5 起可用
PHP_INT_SIZE (integer)
自 PHP 4.4.0 和 PHP 5.0.5 起可用
DEFAULT_INCLUDE_PATH (string)
PEAR_INSTALL_DIR (string)
PEAR_EXTENSION_DIR (string)
PHP_EXTENSION_DIR (string)
PHP_PREFIX (string)
自 PHP 4.3.0 起可用
PHP_BINDIR (string)
PHP_LIBDIR (string)
PHP_DATADIR (string)
PHP_SYSCONFDIR (string)
PHP_LOCALSTATEDIR (string)
PHP_CONFIG_FILE_PATH (string)
PHP_CONFIG_FILE_SCAN_DIR (string)
PHP_SHLIB_SUFFIX (string)
自 PHP 4.3.0 起可用
PHP_OUTPUT_HANDLER_START (integer)
PHP_OUTPUT_HANDLER_CONT (integer)
PHP_OUTPUT_HANDLER_END (integer)
E_ERROR (integer)
E_WARNING (integer)
E_PARSE (integer)
E_NOTICE (integer)
E_CORE_ERROR (integer)
E_CORE_WARNING (integer)
E_COMPILE_ERROR (integer)
E_COMPILE_WARNING (integer)
E_USER_ERROR (integer)
E_USER_WARNING (integer)
E_USER_NOTICE (integer)
E_ALL (integer)
E_STRICT (integer)
從 PHP 5.0.0 起有效
__COMPILER_HALT_OFFSET__ (integer)
自 PHP 5.1.0 起有效
 

標準預定義常量
這些常量是 PHP 默認定義的。

EXTR_OVERWRITE (integer)
EXTR_SKIP (integer)
EXTR_PREFIX_SAME (integer)
EXTR_PREFIX_ALL (integer)
EXTR_PREFIX_INVALID (integer)
EXTR_PREFIX_IF_EXISTS (integer)
EXTR_IF_EXISTS (integer)
SORT_ASC (integer)
SORT_DESC (integer)
SORT_REGULAR (integer)
SORT_NUMERIC (integer)
SORT_STRING (integer)
CASE_LOWER (integer)
CASE_UPPER (integer)
COUNT_NORMAL (integer)
COUNT_RECURSIVE (integer)
ASSERT_ACTIVE (integer)
ASSERT_CALLBACK (integer)
ASSERT_BAIL (integer)
ASSERT_WARNING (integer)
ASSERT_QUIET_EVAL (integer)
CONNECTION_ABORTED (integer)
CONNECTION_NORMAL (integer)
CONNECTION_TIMEOUT (integer)
INI_USER (integer)
INI_PERDIR (integer)
INI_SYSTEM (integer)
INI_ALL (integer)
M_E (float)
M_LOG2E (float)
M_LOG10E (float)
M_LN2 (float)
M_LN10 (float)
M_PI (float)
M_PI_2 (float)
M_PI_4 (float)
M_1_PI (float)
M_2_PI (float)
M_2_SQRTPI (float)
M_SQRT2 (float)
M_SQRT1_2 (float)
CRYPT_SALT_LENGTH (integer)
CRYPT_STD_DES (integer)
CRYPT_EXT_DES (integer)
CRYPT_MD5 (integer)
CRYPT_BLOWFISH (integer)
DIRECTORY_SEPARATOR (string)
SEEK_SET (integer)
SEEK_CUR (integer)
SEEK_END (integer)
LOCK_SH (integer)
LOCK_EX (integer)
LOCK_UN (integer)
LOCK_NB (integer)
HTML_SPECIALCHARS (integer)
HTML_ENTITIES (integer)
ENT_COMPAT (integer)
ENT_QUOTES (integer)
ENT_NOQUOTES (integer)
INFO_GENERAL (integer)
INFO_CREDITS (integer)
INFO_CONFIGURATION (integer)
INFO_MODULES (integer)
INFO_ENVIRONMENT (integer)
INFO_VARIABLES (integer)
INFO_LICENSE (integer)
INFO_ALL (integer)
CREDITS_GROUP (integer)
CREDITS_GENERAL (integer)
CREDITS_SAPI (integer)
CREDITS_MODULES (integer)
CREDITS_DOCS (integer)
CREDITS_FULLPAGE (integer)
CREDITS_QA (integer)
CREDITS_ALL (integer)
STR_PAD_LEFT (integer)
STR_PAD_RIGHT (integer)
STR_PAD_BOTH (integer)
PATHINFO_DIRNAME (integer)
PATHINFO_BASENAME (integer)
PATHINFO_EXTENSION (integer)
PATH_SEPARATOR (string)
CHAR_MAX (integer)
LC_CTYPE (integer)
LC_NUMERIC (integer)
LC_TIME (integer)
LC_COLLATE (integer)
LC_MONETARY (integer)
LC_ALL (integer)
LC_MESSAGES (integer)
ABDAY_1 (integer)
ABDAY_2 (integer)
ABDAY_3 (integer)
ABDAY_4 (integer)
ABDAY_5 (integer)
ABDAY_6 (integer)
ABDAY_7 (integer)
DAY_1 (integer)
DAY_2 (integer)
DAY_3 (integer)
DAY_4 (integer)
DAY_5 (integer)
DAY_6 (integer)
DAY_7 (integer)
ABMON_1 (integer)
ABMON_2 (integer)
ABMON_3 (integer)
ABMON_4 (integer)
ABMON_5 (integer)
ABMON_6 (integer)
ABMON_7 (integer)
ABMON_8 (integer)
ABMON_9 (integer)
ABMON_10 (integer)
ABMON_11 (integer)
ABMON_12 (integer)
MON_1 (integer)
MON_2 (integer)
MON_3 (integer)
MON_4 (integer)
MON_5 (integer)
MON_6 (integer)
MON_7 (integer)
MON_8 (integer)
MON_9 (integer)
MON_10 (integer)
MON_11 (integer)
MON_12 (integer)
AM_STR (integer)
PM_STR (integer)
D_T_FMT (integer)
D_FMT (integer)
T_FMT (integer)
T_FMT_AMPM (integer)
ERA (integer)
ERA_YEAR (integer)
ERA_D_T_FMT (integer)
ERA_D_FMT (integer)
ERA_T_FMT (integer)
ALT_DIGITS (integer)
INT_CURR_SYMBOL (integer)
CURRENCY_SYMBOL (integer)
CRNCYSTR (integer)
MON_DECIMAL_POINT (integer)
MON_THOUSANDS_SEP (integer)
MON_GROUPING (integer)
POSITIVE_SIGN (integer)
NEGATIVE_SIGN (integer)
INT_FRAC_DIGITS (integer)
FRAC_DIGITS (integer)
P_CS_PRECEDES (integer)
P_SEP_BY_SPACE (integer)
N_CS_PRECEDES (integer)
N_SEP_BY_SPACE (integer)
P_SIGN_POSN (integer)
N_SIGN_POSN (integer)
DECIMAL_POINT (integer)
RADIXCHAR (integer)
THOUSANDS_SEP (integer)
THOUSEP (integer)
GROUPING (integer)
YESEXPR (integer)
NOEXPR (integer)
YESSTR (integer)
NOSTR (integer)
CODESET (integer)
LOG_EMERG (integer)
LOG_ALERT (integer)
LOG_CRIT (integer)
LOG_ERR (integer)
LOG_WARNING (integer)
LOG_NOTICE (integer)
LOG_INFO (integer)
LOG_DEBUG (integer)
LOG_KERN (integer)
LOG_USER (integer)
LOG_MAIL (integer)
LOG_DAEMON (integer)
LOG_AUTH (integer)
LOG_SYSLOG (integer)
LOG_LPR (integer)
LOG_NEWS (integer)
LOG_UUCP (integer)
LOG_CRON (integer)
LOG_AUTHPRIV (integer)
LOG_LOCAL0 (integer)
LOG_LOCAL1 (integer)
LOG_LOCAL2 (integer)
LOG_LOCAL3 (integer)
LOG_LOCAL4 (integer)
LOG_LOCAL5 (integer)
LOG_LOCAL6 (integer)
LOG_LOCAL7 (integer)
LOG_PID (integer)
LOG_CONS (integer)
LOG_ODELAY (integer)
LOG_NDELAY (integer)
LOG_NOWAIT (integer)
LOG_PERROR (integer)

標簽:
2011/09/29 at 16:29

php生成excel或者word文檔最簡單的方法

以下代碼實現(xiàn)簡單輸出表格或者word文檔,如生成一個兩列的excel文檔,改動相應文件頭為

header("Content-type:application/vnd.msword");
header("Content-Disposition:filename=test.doc");

就可以輸出.doc .xls等文件格式了

header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls");
echo "test1\t";
echo "test2\t\n"; //兩列之后換行
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";
echo "test1\t";
echo "test2\t\n";

附一個文件格式對應的數(shù)組

$mime_types = array(
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'bmp' => 'image/bmp',
'png' => 'image/png',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'pict' => 'image/x-pict',
'pic' => 'image/x-pict',
'pct' => 'image/x-pict',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'psd' => 'image/x-photoshop',

'swf' => 'application/x-shockwave-flash',
'js' => 'application/x-javascript',
'pdf' => 'application/pdf',
'ps' => 'application/postscript',
'eps' => 'application/postscript',
'ai' => 'application/postscript',
'wmf' => 'application/x-msmetafile',

'css' => 'text/css',
'htm' => 'text/html',
'html' => 'text/html',
'txt' => 'text/plain',
'xml' => 'text/xml',
'wml' => 'text/wml',
'wbmp' => 'image/vnd.wap.wbmp',

'mid' => 'audio/midi',
'wav' => 'audio/wav',
'mp3' => 'audio/mpeg',
'mp2' => 'audio/mpeg',

'avi' => 'video/x-msvideo',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',

'lha' => 'application/x-lha',
'lzh' => 'application/x-lha',
'z' => 'application/x-compress',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'gzip' => 'application/x-gzip',
'tgz' => 'application/x-gzip',
'tar' => 'application/x-tar',
'bz2' => 'application/bzip2',
'zip' => 'application/zip',
'arj' => 'application/x-arj',
'rar' => 'application/x-rar-compressed',

'hqx' => 'application/mac-binhex40',
'sit' => 'application/x-stuffit',
'bin' => 'application/x-macbinary',

'uu' => 'text/x-uuencode',
'uue' => 'text/x-uuencode',

'latex'=> 'application/x-latex',
'ltx' => 'application/x-latex',
'tcl' => 'application/x-tcl',

'pgp' => 'application/pgp',
'asc' => 'application/pgp',
'exe' => 'application/x-msdownload',
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'mdb' => 'application/x-msaccess',
'wri' => 'application/x-mswrite',
);

標簽:, ,
2011/09/29 at 16:25

php獲取訪問者操作系統(tǒng)

function osinfo() {
$os="";
$Agent = $GLOBALS["HTTP_USER_AGENT"];
if (eregi('win',$Agent) && strpos($Agent, '95')) {
$os="Windows 95";
}
elseif (eregi('win 9x',$Agent) && strpos($Agent, '4.90')) {
$os="Windows ME";
}
elseif (eregi('win',$Agent) && ereg('98',$Agent)) {
$os="Windows 98";
}
elseif (eregi('win',$Agent) && eregi('nt 5\.0',$Agent)) {
$os="Windows 2000";
}
elseif (eregi('win',$Agent) && eregi('nt',$Agent)) {
$os="Windows NT";
}
elseif (eregi('win',$Agent) && eregi('nt 5\.1',$Agent)) {
$os="Windows XP";
}
elseif (eregi('win',$Agent) && ereg('32',$Agent)) {
$os="Windows 32";
}
elseif (eregi('linux',$Agent)) {
$os="Linux\";
}
elseif (eregi('unix',$Agent)) {
$os="Unix";
}
elseif (eregi('sun',$Agent) && eregi('os',$Agent)) {
$os="SunOS";
}
elseif (eregi('ibm',$Agent) && eregi('os',$Agent)) {
$os="IBM OS/2";
}
elseif (eregi('Mac',$Agent) && eregi('PC',$Agent)) {
$os="Macintosh";
}
elseif (eregi('PowerPC',$Agent)) {
$os="PowerPC";
}
elseif (eregi('AIX',$Agent)) {
$os="AIX";
}
elseif (eregi('HPUX',$Agent)) {
$os="HPUX";
}
elseif (eregi('NetBSD',$Agent)) {
$os="NetBSD";
}
elseif (eregi('BSD',$Agent)) {
$os="BSD";
}
elseif (ereg('OSF1',$Agent)) {
$os="OSF1";
}
elseif (ereg('IRIX',$Agent)) {
$os="IRIX";
}
elseif (eregi('FreeBSD',$Agent)) {
$os="FreeBSD\";
}
if ($os=='') $os = "Unknown";
return $os;
}

標簽:
comments Comments (258)    -
2011/09/29 at 16:24

php獲取訪問者瀏覽器

以下函數(shù)實現(xiàn)返回瀏覽者所使用的瀏覽器

function browse_infor() {
$browser="";$browserver="";
$Browsers =array("Lynx","MOSAIC","AOL","Opera","JAVA","MacWeb","WebExplorer","OmniWeb");
$Agent = $GLOBALS["HTTP_USER_AGENT"];
for ($i=0; $i<=7; $i++) {
if (strpos($Agent,$Browsers[$i])) {
$browser = $Browsers[$i];
$browserver ="";
}
}
if (ereg("Mozilla",$Agent) && !ereg("MSIE",$Agent)) {
$temp =explode("(", $Agent); $Part=$temp[0];
$temp =explode("/", $Part); $browserver=$temp[1];
$temp =explode(" ",$browserver); $browserver=$temp[0];
$browserver =preg_replace("/([\d\.]+)/","\\1",$browserver);
$browserver = " $browserver";
$browser = "Netscape Navigator";
}
if (ereg("Mozilla",$Agent) && ereg("Opera",$Agent)) {
$temp =explode("(", $Agent); $Part=$temp[1];
$temp =explode(")", $Part); $browserver=$temp[1];
$temp =explode(" ",$browserver);$browserver=$temp[2];
$browserver =preg_replace("/([\d\.]+)/","\\1",$browserver);
$browserver = " $browserver";
$browser = "Opera";
}
if (ereg("Mozilla",$Agent) && ereg("MSIE",$Agent)) {
$temp = explode("(", $Agent); $Part=$temp[1];
$temp = explode(";",$Part); $Part=$temp[1];
$temp = explode(" ",$Part);$browserver=$temp[2];
$browserver =preg_replace("/([\d\.]+)/","\\1",$browserver);
$browserver = " $browserver";
$browser = "Internet Explorer";
}
if ($browser!="") {
$browseinfo = "$browser$browserver";
}else {
$browseinfo = "Unknown";
}
return $browseinfo;
}

標簽:
comments Comments (5)    -
2011/09/29 at 16:20

在IIS中運行php,讓IIS支持php配置方法

1、將 PHP 安裝為 ISAPI 模式:
在“控制面板”的“管理工具”中選擇“Internet 服務管理器”,打開 IIS 后停止服務,然后在左側“默認Web站點”上單擊右鍵選擇“屬性”,在打開的“默認 Web 站點屬性”窗口的“ISAPI 篩選器”標簽里找到并點擊“添加”按鈕,在彈出的“篩選器屬性”窗口中的“篩選器名稱”欄中輸入:PHP,再將可執(zhí)行文件指向 php4isapi.dll 所在路徑,如:C:\PHP\sapi\php4isapi.dll。

2、打開“默認 Web 站點屬性”窗口的“主目錄”標簽,找到并點擊“配置”按鈕,在彈出的“應用程序配置”窗口中找到并點擊“添加”按鈕,在彈出的窗口中新增一個擴展名映射,擴展名為 .php,單擊“瀏覽”將可執(zhí)行文件指向 php4isapi.dll 所在路徑,如:C:\PHP\sapi\php4isapi.dll,然后一路確定即可。如果還想支持諸如 .php3,.phtml 等擴展名的 PHP 文件,可以重復“添加”步驟。

3、再打開“默認 Web 站點屬性”窗口的“的“文檔”標簽,找到并點擊“添加”按鈕,向默認的 Web 站點啟動文檔列表中添加 index.php 項。您可以將 index.php 升到最高優(yōu)先級,這樣,訪問站點時就會首先自動尋找并打開 index.php 文檔。

4、確定 Web 目錄的應用程序設置和執(zhí)行許可中選擇為純腳本,然后關閉 Internet 信息服務管理器,在命令提示符中執(zhí)行如下命令:

net stop w3svc
net stop iisadmin
net start w3svc

5、打開瀏覽器,輸入:http://localhost/,看到成功頁面后,在 IIS 根目錄下新建一個 phpinfo.php,內(nèi)容如下:

<?php
phpinfo();
?>

6、打開瀏覽器,輸入:http://localhost/phpinfo.php,將顯示當前服務器所支持 PHP 的全部信息,可以看到 Server API的模式為:ISAPI。

標簽:,
comments Comments (270)    -
2011/09/23 at 17:46

JS獲取屏幕、瀏覽器、網(wǎng)頁的寬度,高度

網(wǎng)頁可見區(qū)域寬:document.body.clientWidth
網(wǎng)頁可見區(qū)域高:document.body.clientHeight
網(wǎng)頁可見區(qū)域寬:document.body.offsetWidth (包括邊線的寬)
網(wǎng)頁可見區(qū)域高:document.body.offsetHeight (包括邊線的寬)
網(wǎng)頁正文全文寬:document.body.scrollWidth
網(wǎng)頁正文全文高:document.body.scrollHeight
網(wǎng)頁被卷走的高:document.body.scrollTop
網(wǎng)頁被卷走的左:document.body.scrollLeft
網(wǎng)頁正文部分上:window.screenTop
網(wǎng)頁正文部分左:window.screenLeft
屏幕分辨率的高:window.screen.height
屏幕分辨率的寬:window.screen.width
屏幕可用勞動區(qū)高度:window.screen.availHeight
屏幕可用勞動區(qū)寬度:window.screen.availWidth

HTML正確定位:scrollLeft,scrollWidth,clientWidth,offsetWidth

scrollHeight: 獲取東西的轉動高度。

scrollLeft:設置或獲取位于東西左界限和窗口中目前可見內(nèi)容的最左端之間的間隔

scrollTop:設置或獲取位于東西最頂端和窗口中可見內(nèi)容的最頂端之間的間隔

scrollWidth:獲取東西的轉動寬度

offsetHeight:獲取東西盡對付版面或由父坐標 offsetParent 屬指定

的父坐標的高度

offsetLeft:獲取東西盡對付版面或由 offsetParent 屬指定的父坐標的計算左側地位

offsetTop:獲取東西盡對付版面或由 offsetTop 屬指定的父坐標的計算頂端地位

event.clientX 盡對文檔的程度座標

event.clientY 盡對文檔的筆挺座標

event.offsetX 盡對容器的程度坐標

event.offsetY 盡對容器的筆挺坐標

document.documentElement.scrollTop 筆挺偏向轉動的值

event.clientX+document.documentElement.scrollTop 盡對文檔的程度座標+筆挺偏向轉動的量

IE,F(xiàn)ireFox 差別如下:

IE6.0、FF1.06+:

clientWidth = width + padding

clientHeight = height + padding

offsetWidth = width + padding + border

offsetHeight = height + padding + border

IE5.0/5.5:
clientWidth = width - border

clientHeight = height - border

offsetWidth = width

offsetHeight = height

標簽:
comments Comments (18)    -
2011/09/21 at 14:50

mysql所有數(shù)據(jù)庫引擎用法MyISAM、InnoDB、MERGE、MEMORY(HEAP)、BDB(BerkeleyDB)、EXAMPLE、FEDERATED、ARCHIVE、CSV、BLACKHOLE

MySQL有多種存儲引擎,每種存儲引擎有各自的優(yōu)缺點,大家可以擇優(yōu)選擇使用:

MyISAM、InnoDB、MERGE、MEMORY(HEAP)、BDB(BerkeleyDB)、EXAMPLE、FEDERATED、ARCHIVE、CSV、BLACKHOLE。

MySQL支持數(shù)個存儲引擎作為對不同表的類型的處理器。MySQL存儲引擎包括處理事務安全表的引擎和處理非事務安全表的引擎:

· MyISAM管理非事務表。它提供高速存儲和檢索,以及全文搜索能力。MyISAM在所有MySQL配置里被支持,它是默認的存儲引擎,除非你配置MySQL默認使用另外一個引擎。

· MEMORY存儲引擎提供“內(nèi)存中”表。MERGE存儲引擎允許集合將被處理同樣的MyISAM表作為一個單獨的表。就像MyISAM一樣,MEMORY和MERGE存儲引擎處理非事務表,這兩個引擎也都被默認包含在MySQL中。

注釋:MEMORY存儲引擎正式地被確定為HEAP引擎。

· InnoDB和BDB存儲引擎提供事務安全表。BDB被包含在為支持它的操作系統(tǒng)發(fā)布的MySQL-Max二進制分發(fā)版里。InnoDB也默認被包括在所 有MySQL 5.1二進制分發(fā)版里,你可以按照喜好通過配置MySQL來允許或禁止任一引擎。
· EXAMPLE存儲引擎是一個“存根”引擎,它不做什么。你可以用這個引擎創(chuàng)建表,但沒有數(shù)據(jù)被存儲于其中或從其中檢索。這個引擎的目的是服務,在 MySQL源代碼中的一個例子,它演示說明如何開始編寫新存儲引擎。同樣,它的主要興趣是對開發(fā)者。

· NDB Cluster是被MySQL Cluster用來實現(xiàn)分割到多臺計算機上的表的存儲引擎。它在MySQL-Max 5.1二進制分發(fā)版里提供。這個存儲引擎當前只被Linux, Solaris, 和Mac OS X 支持。在未來的MySQL分發(fā)版中,我們想要添加其它平臺對這個引擎的支持,包括Windows。

· ARCHIVE存儲引擎被用來無索引地,非常小地覆蓋存儲的大量數(shù)據(jù)。

· CSV存儲引擎把數(shù)據(jù)以逗號分隔的格式存儲在文本文件中。

· BLACKHOLE存儲引擎接受但不存儲數(shù)據(jù),并且檢索總是返回一個空集。

· FEDERATED存儲引擎把數(shù)據(jù)存在遠程數(shù)據(jù)庫中。在MySQL 5.1中,它只和MySQL一起工作,使用MySQL C Client API。在未來的分發(fā)版中,我們想要讓它使用其它驅動器或客戶端連接方法連接到另外的數(shù)據(jù)源。

當你創(chuàng)建一個新表的時候,你可以通過添加一個ENGINE 或TYPE 選項到CREATE TABLE語句來告訴MySQL你要創(chuàng)建什么類型的表:

CREATE TABLE t (i INT) ENGINE = INNODB;

CREATE TABLE t (i INT) TYPE = MEMORY;

雖然TYPE仍然在MySQL 5.1中被支持,現(xiàn)在ENGINE是首選的術語。

如何選擇最適合你的存儲引擎呢?

下述存儲引擎是最常用的:

· MyISAM:默認的MySQL插件式存儲引擎,它是在Web、數(shù)據(jù)倉儲和其他應用環(huán)境下最常使用的存儲引擎之一。注意,通過更改STORAGE_ENGINE配置變量,能夠方便地更改MySQL服務器的默認存儲引擎。

· InnoDB:用于事務處理應用程序,具有眾多特性,包括ACID事務支持。

· BDB:可替代InnoDB的事務引擎,支持COMMIT、ROLLBACK和其他事務特性。

· Memory:將所有數(shù)據(jù)保存在RAM中,在需要快速查找引用和其他類似數(shù)據(jù)的環(huán)境下,可提供極快的訪問。

· Merge:允許MySQL DBA或開發(fā)人員將一系列等同的MyISAM表以邏輯方式組合在一起,并作為1個對象引用它們。對于諸如數(shù)據(jù)倉儲等VLDB環(huán)境十分適合。

· Archive:為大量很少引用的歷史、歸檔、或安全審計信息的存儲和檢索提供了完美的解決方案。

· Federated:能夠將多個分離的MySQL服務器鏈接起來,從多個物理服務器創(chuàng)建一個邏輯數(shù)據(jù)庫。十分適合于分布式環(huán)境或數(shù)據(jù)集市環(huán)境。

· Cluster/NDB:MySQL的簇式數(shù)據(jù)庫引擎,尤其適合于具有高性能查找要求的應用程序,這類查找需求還要求具有最高的正常工作時間和可用性。

· Other:其他存儲引擎包括CSV(引用由逗號隔開的用作數(shù)據(jù)庫表的文件),Blackhole(用于臨時禁止對數(shù)據(jù)庫的應用程序輸入),以及Example引擎(可為快速創(chuàng)建定制的插件式存儲引擎提供幫助)。

記住,對于整個服務器或方案,你并不一定要使用相同的存儲引擎,你可以為方案中的每個表使用不同的存儲引擎,這點很重要。

mysql> show engines;
+——————–+————+———————————————–———————-—————————–+
| Engine | Support | Comment |
+——————–+————+———————————————————–———————-——————+
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys |
| BerkeleyDB | NO | Supports transactions and page-level locking |
| BLACKHOLE | NO | /dev/null storage engine (anything you write to it disappears) |
| EXAMPLE | NO | Example storage engine |
| ARCHIVE | NO | Archive storage engine |
| CSV | NO | CSV storage engine |
| ndbcluster | NO | Clustered, fault-tolerant, memory-based tables |
| FEDERATED | NO | Federated MySQL storage engine |
| MRG_MYISAM | YES | Collection of identical MyISAM tables |
| ISAM | NO | Obsolete storage engine |
+————+———+—————————————————————————————-+

標簽:
comments Comments (94)    -
2011/09/21 at 14:47

mysql數(shù)據(jù)庫引擎HEAP(MEMORY)的使用,內(nèi)存表,臨時表的用法

HEAP表是訪問數(shù)據(jù)速度最快的MySQL表,他使用保存在內(nèi)存中的散列索引。但如果MySQL或者服務器重新啟動,表中數(shù)據(jù)將會丟失.
用法:如論壇的在線人數(shù)統(tǒng)計,這種表的數(shù)據(jù)應該是無關緊要的,就幾個簡單的字段,數(shù)據(jù)也不多,記錄數(shù)怎么也不會超過1000吧,但是操作是最頻繁的(基本用戶的每次動作都要更新這個表).

如何創(chuàng)建內(nèi)存表?
創(chuàng)建內(nèi)存表非常的簡單,只需注明 ENGINE= MEMORY 即可:
CREATE TABLE `tablename` ( `columnName` varchar(256) NOT NUL) ENGINE=MEMORY DEFAULT CHARSET=latin1 MAX_ROWS=100000000;

注意:
當內(nèi)存表中的數(shù)據(jù)大于max_heap_table_size設定的容量大小時,mysql會轉換超出的數(shù)據(jù)存儲到磁盤上,因此這是性能就大打折扣了,所 以我們還需要根據(jù)我們的實際情況調整max_heap_table_size,例如在.cnf文件中[mysqld]的下面加入:
max_heap_table_size = 2048M
另外在建表語句中還可以通過MAX_ROWS來控制表的記錄數(shù)。

內(nèi)存表使用哈希散列索引把數(shù)據(jù)保存在內(nèi)存中,因此具有極快的速度,適合緩存中小型數(shù)據(jù)庫,但是使用上受到一些限制。

1、heap對所有用戶的連接是可見的,這使得它非常適合做緩存。

2、僅適合使用的場合。heap不允許使用xxxTEXT和xxxBLOB數(shù)據(jù)類型;只允許使用=和&lt;=&gt;操作符來搜索記錄 (不允許&lt;、&gt;、&lt;=或&gt;=);不支持auto_increment;只允許對非空數(shù)據(jù)列進行 索引(not null)。
注:操作符 “&lt;=&gt;” 說明:NULL-safe equal.這個操作符和“=”操作符執(zhí)行相同的比較操作,不過在兩個操作碼均為NULL時,其所得值為1而不為NULL,而當一個操作碼為NULL時,其所得值為0而不為NULL。

3、一旦服務器重啟,所有heap表數(shù)據(jù)丟失,但是heap表結構仍然存在,因為heap表結構是存放在實際數(shù)據(jù)庫路徑下的,不會自動刪除。重啟之后,heap將被清空,這時候對heap的查詢結果都是空的。

4、如果heap是復制的某數(shù)據(jù)表,則復制之后所有主鍵、索引、自增等格式將不復存在,需要重新添加主鍵和索引,如果需要的話。

5、對于重啟造成的數(shù)據(jù)丟失,有以下的解決辦法:
a、在任何查詢之前,執(zhí)行一次簡單的查詢,判斷heap表是否存在數(shù)據(jù),如果不存在,則把數(shù)據(jù)重新寫入,或者DROP表重新復制某張表。這需要多做一次查詢。不過可以寫成include文件,在需要用該heap表的頁面隨時調用,比較方便。
b、對于需要該heap表的頁面,在該頁面第一次且僅在第一次查詢該表時,對數(shù)據(jù)集結果進行判斷,如果結果為空,則需要重新寫入數(shù)據(jù)。這樣可以節(jié)省一次查詢。
c、更好的辦法是在mysql每次重新啟動時自動寫入數(shù)據(jù)到heap,但是需要配置服務器,過程比較復雜,通用性受到限制。

6、一些預期可能用到的sql語句

//如果表存在,則刪除
DROP TABLE IF EXISTS `abc`;
//復制整張表xyz為heap表abc(包含所有數(shù)據(jù))
CREATE TABLE `abc` type=heap select * from `xyz`;
//添加主鍵id
ALTER TABLE `abc` ADD PRIMARY KEY (`id`);
//添加索引username
ALTER TABLE `abc` ADD INDEX `abc` (`username`);

其它參考:
官方文檔:As indicated by the name, MEMORY tables are stored in memory. They use hash indexes by default, which makes them very fast, and very useful for creating temporary tables. However, when the server shuts down, all rows stored in MEMORY tables are lost. The tables themselves continue to exist because their definitions are stored in .frm files on disk, but they are empty when the server restarts.

可以看出來MEMORY確實是very fast,and very useful for creating temporary tables .把臨時表和內(nèi)存表放在一起使用確實會快不少:create table tmp2(id int not null) engine memory;
內(nèi)存表的建立還有一些限制條件:
MEMORY tables cannot contain BLOB or TEXT columns. HEAP不支持BLOB/TEXT列。
The server needs sufficient memory to maintain all MEMORY tables that are in use at the same time. 在同一時間需要足夠的內(nèi)存.
To free memory used by a MEMORY table when you no longer require its contents, you should execute DELETE or TRUNCATE TABLE, or remove the table altogether using DROP TABLE.為了釋放內(nèi)存,你應該執(zhí)行DELETE FROM heap_table或DROP TABLE heap_table。

幾個關鍵參數(shù)

max_heap_table_size
mysql HEAP MEMORY tables 提高行數(shù)支持的方法
別人問到的 記一下
mysql MEMORY tables 如果目前支持的行數(shù)到上限還不夠用 可以把 my.conf 配置里面
max_heap_table_size = 256M
改大
設置 MAX_ROWS
在跑著 可以 ALTER TABLE tbl_name MAX_ROWS=
MAX_ROWS 依賴于 max_heap_table_size 設置

標簽:,
comments Comments (407)    -
2011/09/12 at 14:20

dede 在列表頁和文章頁調用全站最新文章

dede在首頁調用全站最新文章是這樣實現(xiàn)的

{dede:arclist titlelen=42 row=6 }
<li><a href="[field:arcurl/]">[field:title/]</a>
<p>[field:description function='cn_substr(@me,80)'/]...</p>
</li>
{/dede:arclist}

這種方式只有在首頁調用出來才是全站最新的文章,在列表頁或者文章頁調出來的是本欄目下的文章,這是系統(tǒng)固定好的,如果希望在列表頁和文章頁也調用全站的內(nèi)容,需要加上 typeid='top'這個標簽屬性,typeid也可以指定特定的頂級欄目id。

{dede:arclist titlelen=42 row=6 typeid='top'}
<li><a href="[field:arcurl/]">[field:title/]</a>
<p>[field:description function='cn_substr(@me,80)'/]...</p>
</li>
{/dede:arclist}

標簽:
comments Comments (452)    -
2011/09/10 at 20:56

廣珠城軌中山售票點-中山城軌代售點電話地址

廣珠城軌目前在中山的售票點有10個,市民可在這10個代售網(wǎng)點購買任意站點的城軌票。這10個代售點分布范圍很廣:沙溪有1個,火炬區(qū)有2個,小欖2個,城區(qū)2個,東升、三鄉(xiāng)、古鎮(zhèn)各1個。市民可就近購票,無需直接前往城軌站場購票。

廣珠城軌代售網(wǎng)點名單:

1,永佳火車售票處,沙溪鎮(zhèn)西區(qū)水牛城商業(yè)廣場51卡。電話:0760-87390156

2,金箭有限公司航空服務分公司(中山港壹加壹超市附近),火炬區(qū)集中新建區(qū)興隆街22棟23-24卡。電話:0760-85591298

3,盛源商務有限公司,小欖鎮(zhèn)沙口小欖大道25號。電話:0760-23820825

4,菊城假日國際旅行社有限公司,小欖新市路95號。電話:0760-22281407

5,祥達航空服務有限公司,中山三路3號。電話:0760-8324120

6,鐵青中山東升營業(yè)處,東升鎮(zhèn)葵興大道97號之二。電話:020-61351236

7,交通運輸倉儲配載中心,中山四路33號。電話:0760-88322990

8,三鄉(xiāng)廣安售票處,三鄉(xiāng)鎮(zhèn)文安路(三鄉(xiāng)汽車站內(nèi))。電話:0760-86693815

9,通達售票服務部,火炬區(qū)東鎮(zhèn)大道15號第二卡。電話:0760-88287148

10,古鎮(zhèn)華程票務部,古鎮(zhèn)鎮(zhèn)興路4號之三。電話:0760-2324518

標簽:, ,
comments Comments (7)    -