編程函數
相關函數:open, ftruncaten
表頭文件:#include
定義函數:int truncate(const char *path, off_t length);
函數說明:truncate()會将參數path指定的文件大小改為參數length指定的大小。 如果原來的文件大小比參數length大,則超過的部分會被删除
返回值:執行成功則返回0, 失敗返回-1, 錯誤原因存于errno
錯誤代碼:EACCESS 參數path所指定的文件無法存取
EROFS 欲寫入的文件存在于隻讀文件系統内
EFAULT 參數path指針超出可存取空間
EINVAL 參數path包含不合法字符
ENAMETOOLONG 參數path太長
ENOTDIR 參數path路徑并非一目錄
EISDIR 參數path指向一目錄
ETXTBUSY 參數path所指的文件為共享程序,而且正被執行中
ELOOP 參數path有過多符号連接問題
EIO I/O存取錯誤
操作語句
使用方法
truncate table table_name;
操作特性
truncate 隻删除表中的所有數據,不删除表的結構;
truncate 是ddl操作立即生效,原數據不放到rollback segment中,不能回滾,操作不觸發trigger;
truncate 語句缺省情況下将空間釋放到 minextents個 extent,除非使用reuse storage;
truncate 會将高水線複位(回到最開始)。
符串函數
smartytruncate截取
從字符串開始處截取某長度的字符.默認是80個。
你也可以指定第二個參數作為追加在截取字符串後面的文本字串.該追加字串被計算在截取長度中。
默認情況下,smarty會截取到一個詞的末尾。
如果你想要精确的截取多少個字符,把第三個參數改為"true" 。
例截取
index.php:
$smarty = new Smarty;
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
$smarty->display('index.tpl');
index.tpl:
{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}
輸出結果
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after...
Two Sisters Reunite after
Two Sisters Reunite after---
Two Sisters Reunite after Eigh
Two Sisters Reunite after E...



















