Linux sort的常用
按照第5個字段進行排序
[root@test2 smartlsData]# ll | sort -t : +5n-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 20580 12月22 18:40 ACode.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 AnTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx
按照純數字進行排序(否則按照字母方式進行排序)
[root@test2 smartlsData]# ll | sort -n-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 20580 12月22 18:40 ACode.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 AnTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx總用量 390484
Linux wc 的使用
wc -l 行號
wc -m
wc -w
[root@test2 smartlsData]# ll | wc -l13
替換
[root@test2 smartlsData]# ll | tr -d 'A'總用量 390484-rwxrwxrwx 1 root root 20580 12月22 18:40 Code.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 nTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt
[root@test2 smartlsData]# ll | cut -d " " -f 4
rootrootrootrootrootrootrootrootrootrootrootroot
拆分 按照大小 和 行 來拆分
split -b 1m detailWebsite.htm detailWebsite.htm_split -l 5 detailWebsite.htm detailWebsite.htm_
2011年11月15日 星期二
yum 收藏的php pear庫
yum list |grep php-pear|cut -d " " -f 1
php-pear.noarch
php-pear-Auth.noarch
php-pear-Auth-OpenID.noarch
php-pear-Auth-RADIUS.noarch
php-pear-Auth-SASL.noarch
php-pear-Auth-Yubico.noarch
php-pear-Auth-radius.noarch
php-pear-Auth-samba.noarch
php-pear-Auth_HTTP.noarch
php-pear-Benchmark.noarch
php-pear-CAS.noarch
php-pear-Cache.noarch
php-pear-Cache-Lite.noarch
php-pear-CodeGen.noarch
php-pear-CodeGen-PECL.noarch
php-pear-Console-Color.noarch
php-pear-Console-CommandLine.noarch
php-pear-Console-Getargs.noarch
php-pear-Console-ProgressBar.noarch
php-pear-Console-Table.noarch
php-pear-Crypt-Blowfish.noarch
php-pear-Crypt-CHAP.noarch
php-pear-DB.noarch
php-pear-DB-DataObject.noarch
php-pear-DB-DataObject-FormBuilder.noarch
php-pear-DB-QueryTool.noarch
php-pear-Date.noarch
php-pear-Date-Holidays.noarch
php-pear-Date-Holidays-USA.noarch
php-pear-Event-Dispatcher.noarch
php-pear-File.noarch
php-pear-File-Bittorrent2.noarch
php-pear-File-Find.noarch
php-pear-File-Passwd.noarch
php-pear-File-SMBPasswd.noarch
php-pear-HTML-Common.noarch
php-pear-HTML-QuickForm.noarch
php-pear-HTML-QuickForm-ElementGrid.noarch
php-pear-HTML-QuickForm-advmultiselect.noarch
php-pear-HTML-Table.noarch
php-pear-HTML-Template-IT.noarch
php-pear-HTML_Javascript.noarch
php-pear-HTML_Template_PHPLIB.noarch
php-pear-HTTP.noarch
php-pear-HTTP-Client.noarch
php-pear-HTTP-OAuth.noarch
php-pear-HTTP-Request.noarch
php-pear-HTTP-Request2.noarch
php-pear-HTTP-Upload.noarch
php-pear-Image-Canvas.noarch
php-pear-Image-Color.noarch
php-pear-Image-Graph.noarch
php-pear-Image-GraphViz.noarch
php-pear-Log.noarch
php-pear-MDB2.noarch
php-pear-MDB2-Driver-mysql.noarch
php-pear-MDB2-Driver-mysqli.noarch
php-pear-MDB2-Driver-pgsql.noarch
php-pear-MDB2-Schema.noarch
php-pear-Mail.noarch
php-pear-Mail-Mime.noarch
php-pear-Mail-mimeDecode.noarch
php-pear-Math-Stats.noarch
php-pear-Net-Curl.noarch
php-pear-Net-DIME.noarch
php-pear-Net-DNS.noarch
php-pear-Net-FTP.noarch
php-pear-Net-IDNA2.noarch
php-pear-Net-IPv4.noarch
php-pear-Net-POP3.noarch
php-pear-Net-Ping.noarch
php-pear-Net-SMTP.noarch
php-pear-Net-Sieve.noarch
php-pear-Net-Socket.noarch
php-pear-Net-Traceroute.noarch
php-pear-Net-URL.noarch
php-pear-Net-URL-Mapper.noarch
php-pear-Net-URL2.noarch
php-pear-Net-UserAgent-Detect.noarch
php-pear-Numbers-Roman.noarch
php-pear-Numbers-Words.noarch
php-pear-OLE.noarch
php-pear-PEAR-Command-Packaging.noarch
php-pear-PHP-CodeSniffer.noarch
php-pear-PHP-Compat.noarch
php-pear-PHP-CompatInfo.noarch
php-pear-Pager.noarch
php-pear-Payment-Process.noarch
php-pear-PhpDocumentor.noarch
php-pear-PhpDocumentor-docs.noarch
php-pear-SOAP.noarch
php-pear-Services-Twitter.noarch
php-pear-Services-Weather.noarch
php-pear-Spreadsheet-Excel-Writer.noarch
php-pear-Structures-DataGrid.noarch
php-pear-Structures-DataGrid-DataSource-Array.noarch
php-pear-Structures-DataGrid-DataSource-DataObject.noarch
php-pear-Structures-DataGrid-DataSource-MDB2.noarch
php-pear-Structures-DataGrid-DataSource-RSS.noarch
php-pear-Structures-DataGrid-Renderer-Pager.noarch
php-pear-Structures-DataGrid-Renderer-Smarty.noarch
php-pear-Text-Diff.noarch
php-pear-Validate.noarch
php-pear-Validate-Finance-CreditCard.noarch
php-pear-Var-Dump.noarch
php-pear-XML-Beautifier.noarch
php-pear-XML-Parser.noarch
php-pear-XML-RPC2.noarch
php-pear-XML-RSS.noarch
php-pear-XML-Serializer.noarch
php-pear-phing.noarch
php-pear.noarch
php-pear-Auth.noarch
php-pear-Auth-OpenID.noarch
php-pear-Auth-RADIUS.noarch
php-pear-Auth-SASL.noarch
php-pear-Auth-Yubico.noarch
php-pear-Auth-radius.noarch
php-pear-Auth-samba.noarch
php-pear-Auth_HTTP.noarch
php-pear-Benchmark.noarch
php-pear-CAS.noarch
php-pear-Cache.noarch
php-pear-Cache-Lite.noarch
php-pear-CodeGen.noarch
php-pear-CodeGen-PECL.noarch
php-pear-Console-Color.noarch
php-pear-Console-CommandLine.noarch
php-pear-Console-Getargs.noarch
php-pear-Console-ProgressBar.noarch
php-pear-Console-Table.noarch
php-pear-Crypt-Blowfish.noarch
php-pear-Crypt-CHAP.noarch
php-pear-DB.noarch
php-pear-DB-DataObject.noarch
php-pear-DB-DataObject-FormBuilder.noarch
php-pear-DB-QueryTool.noarch
php-pear-Date.noarch
php-pear-Date-Holidays.noarch
php-pear-Date-Holidays-USA.noarch
php-pear-Event-Dispatcher.noarch
php-pear-File.noarch
php-pear-File-Bittorrent2.noarch
php-pear-File-Find.noarch
php-pear-File-Passwd.noarch
php-pear-File-SMBPasswd.noarch
php-pear-HTML-Common.noarch
php-pear-HTML-QuickForm.noarch
php-pear-HTML-QuickForm-ElementGrid.noarch
php-pear-HTML-QuickForm-advmultiselect.noarch
php-pear-HTML-Table.noarch
php-pear-HTML-Template-IT.noarch
php-pear-HTML_Javascript.noarch
php-pear-HTML_Template_PHPLIB.noarch
php-pear-HTTP.noarch
php-pear-HTTP-Client.noarch
php-pear-HTTP-OAuth.noarch
php-pear-HTTP-Request.noarch
php-pear-HTTP-Request2.noarch
php-pear-HTTP-Upload.noarch
php-pear-Image-Canvas.noarch
php-pear-Image-Color.noarch
php-pear-Image-Graph.noarch
php-pear-Image-GraphViz.noarch
php-pear-Log.noarch
php-pear-MDB2.noarch
php-pear-MDB2-Driver-mysql.noarch
php-pear-MDB2-Driver-mysqli.noarch
php-pear-MDB2-Driver-pgsql.noarch
php-pear-MDB2-Schema.noarch
php-pear-Mail.noarch
php-pear-Mail-Mime.noarch
php-pear-Mail-mimeDecode.noarch
php-pear-Math-Stats.noarch
php-pear-Net-Curl.noarch
php-pear-Net-DIME.noarch
php-pear-Net-DNS.noarch
php-pear-Net-FTP.noarch
php-pear-Net-IDNA2.noarch
php-pear-Net-IPv4.noarch
php-pear-Net-POP3.noarch
php-pear-Net-Ping.noarch
php-pear-Net-SMTP.noarch
php-pear-Net-Sieve.noarch
php-pear-Net-Socket.noarch
php-pear-Net-Traceroute.noarch
php-pear-Net-URL.noarch
php-pear-Net-URL-Mapper.noarch
php-pear-Net-URL2.noarch
php-pear-Net-UserAgent-Detect.noarch
php-pear-Numbers-Roman.noarch
php-pear-Numbers-Words.noarch
php-pear-OLE.noarch
php-pear-PEAR-Command-Packaging.noarch
php-pear-PHP-CodeSniffer.noarch
php-pear-PHP-Compat.noarch
php-pear-PHP-CompatInfo.noarch
php-pear-Pager.noarch
php-pear-Payment-Process.noarch
php-pear-PhpDocumentor.noarch
php-pear-PhpDocumentor-docs.noarch
php-pear-SOAP.noarch
php-pear-Services-Twitter.noarch
php-pear-Services-Weather.noarch
php-pear-Spreadsheet-Excel-Writer.noarch
php-pear-Structures-DataGrid.noarch
php-pear-Structures-DataGrid-DataSource-Array.noarch
php-pear-Structures-DataGrid-DataSource-DataObject.noarch
php-pear-Structures-DataGrid-DataSource-MDB2.noarch
php-pear-Structures-DataGrid-DataSource-RSS.noarch
php-pear-Structures-DataGrid-Renderer-Pager.noarch
php-pear-Structures-DataGrid-Renderer-Smarty.noarch
php-pear-Text-Diff.noarch
php-pear-Validate.noarch
php-pear-Validate-Finance-CreditCard.noarch
php-pear-Var-Dump.noarch
php-pear-XML-Beautifier.noarch
php-pear-XML-Parser.noarch
php-pear-XML-RPC2.noarch
php-pear-XML-RSS.noarch
php-pear-XML-Serializer.noarch
php-pear-phing.noarch
Additional PEAR Library
PHPUnit (for Unit Testing)
- URL: http://pear.php.net/package/PHPUnit2/
- Home URL: http://www.phpunit.de/
- Stable version: 2.3.6
- Download URL: http://pear.php.net/package/PHPUnit2/download
- Installed Servers: vm1, vm2
- Path: /opt/php/lib/php/PHPUnit/
PHPMailer
- Home URL: http://phpmailer.codeworxtech.com/
- Latest version: 2.2.1
- Download URL: http://phpmailer.codeworxtech.com/index.php?pg=sf&p=dl
- Installed Servers: vm1, vm2
- Path: /opt/php/lib/php/PHPMailer/
Zend Framework
- Home URL: http://framework.zend.com/
- Latest version: 1.6.1
- Download URL: http://framework.zend.com/download/latest
- Installed Server: vm2 (for admin system development)
- Path: /opt/php/lib/php/Zend/
PEAR Package - Excel and Spreadsheet (Reference Only)
- Spreadsheet_Excel_Writer: http://pear.php.net/package/Spreadsheet_Excel_Writer
- Structures_DataGrid_DataSource_Excel: http://pear.php.net/package/Structures_DataGrid_DataSource_Excel
- Structures_DataGrid: http://pear.php.net/package/Structures_DataGrid
- Structures_DataGrid_DataSource_Array: http://pear.php.net/package/Structures_DataGrid_DataSource_Array
- Structures_DataGrid_Renderer_XLS: http://pear.php.net/package/Structures_DataGrid_Renderer_XLS/
Reference
PHP - Email
- PHP Mail Library Presentation: http://www.phplondon.org/conference/2008/media/docs/marcus_bointon_mail_presentation.pdf
- PHPMailer Tips and Tools: http://phpmailer.codeworxtech.com/index.php?pg=tips
- Sending Email with Zend Framework: http://www.talkphp.com/vbarticles.php?do=article&articleid=51&title=sending-emails-with-the-zend-framework
Bounce Email Tracking
- URL: http://forums.devshed.com/php-development-5/bounce-e-mail-tracking-522635.html
- Steps to detect bounce emails: http://www.php.net/manual/sk/ref.mail.php#24963
- PHP class for tracking bounce emails: http://www.phpclasses.org/browse/package/2691.html
- Article on Incoming mails and php: http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/
PHP Bulk Email - Best Practice
phplist Features
Wiki
- Bounce Message: http://en.wikipedia.org/wiki/Bounce_message
- Bounce Address Tag Validation (BATV): http://en.wikipedia.org/wiki/Bounce_Address_Tag_Validation
- Sender Policy Framework (SPF): http://en.wikipedia.org/wiki/Sender_Policy_Framework
- Simple Mail Transfer Protocol (SMTP): http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol
- Variable Envelope Return Path (VERP): http://en.wikipedia.org/wiki/Variable_envelope_return_path
Software
- Email Marketing Software (Mach5 Mailer): http://www.mach5.com/products/mailer/index.php
- Email Bounce Handling Solution: http://www.boogietools.com/
2011年11月14日 星期一
Zend Framework 輸出xml的幾種方法
Zend Framework 輸出xml的幾種方法。
見代碼:1.
class TestController extends Zend_Controller_Action {
/**
* The default action - show the home page
*/
public function indexAction() {
$content = "bar ";
header('Content-Type: text/xml');
echo $content;
exit;
}
}
加一句exit;這樣可以不用關閉view.
2.
class TestController extends Zend_Controller_Action {
/**
* The default action - show the home page
*/
public function indexAction() {
// XML-related routine
$xml = new DOMDocument('1.0', 'utf-8');
$xml->appendChild($xml->createElement('foo', 'bar'));
$output = $xml->saveXML();
// Both layout and view renderer should be disabled
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
Zend_Layout::getMvcInstance()->disableLayout();
// Setting up headers and body
$this->_response->setHeader('Content-Type', 'text/xml; charset=utf-8')
->setBody($output);
}
}
第二種方法可以調用DOMDocument對象來創建更豐富的xml.
本文出自“Bob” 博客,請務必保留此出處http://phpbob.blog.51cto.com/636017/631102
見代碼:1.
class TestController extends Zend_Controller_Action {
/**
* The default action - show the home page
*/
public function indexAction() {
$content = "
header('Content-Type: text/xml');
echo $content;
exit;
}
}
加一句exit;這樣可以不用關閉view.
2.
class TestController extends Zend_Controller_Action {
/**
* The default action - show the home page
*/
public function indexAction() {
// XML-related routine
$xml = new DOMDocument('1.0', 'utf-8');
$xml->appendChild($xml->createElement('foo', 'bar'));
$output = $xml->saveXML();
// Both layout and view renderer should be disabled
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setNoRender(true);
Zend_Layout::getMvcInstance()->disableLayout();
// Setting up headers and body
$this->_response->setHeader('Content-Type', 'text/xml; charset=utf-8')
->setBody($output);
}
}
第二種方法可以調用DOMDocument對象來創建更豐富的xml.
本文出自“Bob” 博客,請務必保留此出處http://phpbob.blog.51cto.com/636017/631102
2011年10月3日 星期一
Function session_register() is deprecated
session_register()函式在php5.3環境下
是不給用的
建議
if(session_register( “abc” )){
echo 'XXX';
}
改為
if($_SESSION['abc'] = null){
echo 'XXX';
}
是不給用的
建議
if(session_register( “abc” )){
echo 'XXX';
}
改為
if($_SESSION['abc'] = null){
echo 'XXX';
}
function ereg() is deprecated
php5.3之後關於正規表示式會出現錯誤
function ereg() is deprecated
請修改函式
ereg("^[0-9]*$",$page)
為
preg_match("/^[0-9]*$/",$page)
function eregi() is deprecated
eregi("^[0-9]*$",$page)
為
preg_match("/^[0-9]*$/i",$page)
function split is deprecated
split函式改為
explode
如果第一個參數為正規表示式則改為
preg_split
function ereg_replace is deprecated
$t_lang_var = ereg_replace( '^TLS_', '', $t_var );
改為
$t_lang_var = preg_replace( '/^TLS_/', '', $t_var );
2011年7月17日 星期日
ZF 在多個地方放置模組
如果想將模組分為核心及外加模組,可透過ZF本身定義設定檔的方式
由
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
修改為
resources.frontController.moduleDirectory[] = APPLICATION_PATH "/modules/core"
resources.frontController.moduleDirectory[] = APPLICATION_PATH "/modules/local"
可以定義多個放置module位置
由
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
修改為
resources.frontController.moduleDirectory[] = APPLICATION_PATH "/modules/core"
resources.frontController.moduleDirectory[] = APPLICATION_PATH "/modules/local"
可以定義多個放置module位置
2011年7月5日 星期二
PHP讀取資料夾內檔案列表
PHP的內建函式,以物件的方式處理,可以用來顯示資料夾內的檔案
$d = dir($Path);
while( $entry = $d->read() ){
if ($entry!= “.” && $entry!= “..”) {
}
}
closedir($d);
$d = dir($Path);
while( $entry = $d->read() ){
if ($entry!= “.” && $entry!= “..”) {
}
}
closedir($d);
2011年7月3日 星期日
2011年4月22日 星期五
ZendFramework使用FreeTDS連接Sybase
請務必把/etc/freetds.conf
中該資料庫 的TDS版本 設定為tds version = 6.3 或 6.0才會正常
ZF的INI設定
resources.db.adapter = "PDO_MSSQL"
resources.db.params.pdoType = "dblib"
resources.db.params.host = "名稱"
resources.db.params.username = "帳號"
resources.db.params.password = "密碼"
resources.db.params.dbname = "資料庫名稱"
如果沒有設成tds version = 6.3
會有登入錯誤的問題
(SQLSTATE[28000] Login incorrect. (severity 9) )
參考
http://blog.wabow.com/archives/335
中該資料庫 的TDS版本 設定為tds version = 6.3 或 6.0才會正常
ZF的INI設定
resources.db.adapter = "PDO_MSSQL"
resources.db.params.pdoType = "dblib"
resources.db.params.host = "名稱"
resources.db.params.username = "帳號"
resources.db.params.password = "密碼"
resources.db.params.dbname = "資料庫名稱"
如果沒有設成tds version = 6.3
會有登入錯誤的問題
(SQLSTATE[28000] Login incorrect. (severity 9) )
參考
http://blog.wabow.com/archives/335
2011年4月17日 星期日
PHP的__call
在Ruby中如果呼叫該物件沒有的方法時可透過(method_missin)來處理
如果是PHP則透過
def method_missing(id, *args) return self.find(Regexp.last_match(1), args[0]) if id.id2name =~ /find_by_(.+)/ raise NoMethodError end
如果是PHP則透過
__call來達到同等的目的
詳見
活用 PHP5 的 magic methods
2011年4月7日 星期四
ZendFramework的分頁
網路上很像很少人在講Zend_Paginator::factory
這個ZF原裝分頁類
在初始化(factory)時,可以用ZF_model或array都可以分頁
$Plists = $qunit -> getList(0);
//分頁設定
$limit = $this -> _getParam('limit', 10);
$page = $this -> _getParam('page', 1);
//分頁
$paginator = Zend_Paginator::factory($Plists);
$paginator -> setCurrentPageNumber($page)
-> setItemCountPerPage($limit);
$uCount = $paginator ->getTotalItemCount();
$this -> view ->assign('fromData', $paginator);
$uCount 總筆數
$limit 每頁筆數
$page 預設從第幾頁開始
$paginator 分頁處理後的資料集
2011年4月6日 星期三
ZendFramework的預設route
當我們的網址Action 為group-user-add時
ctrl會對應至public function groupUserAddAction()
而 view會對應至group-user-add.phtml
當使用group_user_add時
ctrl會對應至groupuseradd
而view還是會對應至group-user-add.phtml
ctrl會對應至public function groupUserAddAction()
而 view會對應至group-user-add.phtml
當使用group_user_add時
ctrl會對應至groupuseradd
而view還是會對應至group-user-add.phtml
所以可以利用下底線的組合來共用同名ctrl切換不同view?
是偶然嗎?
2011年4月1日 星期五
2011年3月30日 星期三
Zend_Cache 檔案快取
//設定緩存生命期
$frontendOptions = array('lifeTime' =>5, // 5秒
’automatic_serialization’ => true);
//放緩存文件的目錄);
$backendOptions = array('cache_dir' => './temp/cache');
//取得一個Zend_Cache_Core 對象
$cache = Zend_Cache::factory('Core','File',$frontendOptions,$backendOptions);
//取緩存數據
if(!$cacheBuffer = $cache->load(‘mycache’)){
//如果沒有命中,則重新生成緩存
$data=array(
”測試zend 的 cache”,time()
);
//將數據系列化後存入緩存文件
$cache->save($data, ‘mycache’);
//echo “ok”;
}else{
//將取出的數據反序列列化
$data=unserialize($cacheBuffer);
}
$frontendOptions = array('lifeTime' =>5, // 5秒
’automatic_serialization’ => true);
//放緩存文件的目錄);
$backendOptions = array('cache_dir' => './temp/cache');
//取得一個Zend_Cache_Core 對象
$cache = Zend_Cache::factory('Core','File',$frontendOptions,$backendOptions);
//取緩存數據
if(!$cacheBuffer = $cache->load(‘mycache’)){
//如果沒有命中,則重新生成緩存
$data=array(
”測試zend 的 cache”,time()
);
//將數據系列化後存入緩存文件
$cache->save($data, ‘mycache’);
//echo “ok”;
}else{
//將取出的數據反序列列化
$data=unserialize($cacheBuffer);
}
2011年3月18日 星期五
php-migrations
在ruby中有方便的
rake db:migrate
可以在開發環境中方便的做
資料庫的版本控制(結構的新增與回復)
PHP也有clone的版本
mysql-php-migrations
http://code.google.com/p/mysql-php-migrations/
使用方式
執行
php migrate.php add
會依日期建立某版本號
在其中
public function up(PDO &$pdo) { $pdo->exec("ALTER TABLE `test0` ADD `field1` VARCHAR(24) NOT NULL"); } public function down(PDO &$pdo) { $pdo->exec("ALTER TABLE `test0` DROP `field1`"); }
去寫新增或回滾的SQL語法就行
2011年3月1日 星期二
網頁強制不緩衝(HTML & PHP)
HTML
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
PHP
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false );
header('Pragma: no-cache');
資料來源:
HTML、ASP、PHP 強制不緩存頁面代碼(SOUGEE)
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
PHP
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false );
header('Pragma: no-cache');
資料來源:
HTML、ASP、PHP 強制不緩存頁面代碼(SOUGEE)
2011年2月11日 星期五
Sybase datetime格式
Sybase中的date格式需使用date轉成ISO8601標準格式寫入
比較時間也是
先轉為時間戳記在轉為YMD
date('Y-m-d H:i:s',strtotime($rs['sendDate']))
date( "Y-m-d", strtotime($mInfo['PubDate']))
比較時間也是
先轉為時間戳記在轉為YMD
date('Y-m-d H:i:s',strtotime($rs['sendDate']))
date( "Y-m-d", strtotime($mInfo['PubDate']))
2011年2月10日 星期四
Zend Framework連接Sybase
使用ZendFrame work時需在主機上安裝
dblib
指定設定檔的
resources.db.adapter = "PDO_MSSQL"
resources.db.params.pdoType = "dblib"
在zend model update會發生型態問題
Implicit conversion from datatype 'VARCHAR' to 'INT' is not allowed
不知為什麼ZF不判斷型態
可透過
protected $_metadata = array(
dblib
指定設定檔的
resources.db.adapter = "PDO_MSSQL"
resources.db.params.pdoType = "dblib"
在zend model update會發生型態問題
Implicit conversion from datatype 'VARCHAR' to 'INT' is not allowed
不知為什麼ZF不判斷型態
可透過
protected $_metadata = array(
'SCHEMA_NAME' => ,
'TABLE_NAME' => ,
'COLUMN_NAME' => ,
'COLUMN_POSITION' => ,
'DATA_TYPE' => ,
'DEFAULT' => NULL|,
'NULLABLE' => ,
'LENGTH' => ,
'SCALE' => NULL|,
'PRECISION' => NULL|,
'UNSIGNED' => NULL|,
'PRIMARY' => ,
'PRIMARY_POSITION' => ,
'IDENTITY' => ,
),
// additional columns...
);
自行定義 metadata
或在data中使用SQL轉型
'sort_no' => new Zend_Db_Expr('convert(int,' . $sort_no . ') ')
Sybase轉型為int型態
convert(int,' . $sort_no . ')
目前沒在mysql上發現問題,在Sybase卡了很久,使用settype()及(int)在PHP上轉型
進入ZF的update後!!都不行只好透過以上方法!!
自動編號需使用identity
自動編號需使用identity
訂閱:
文章 (Atom)