-
truncate
(計算機函數)
鎖定
truncate指的是一種計算機語言函數,使用方法是truncate table table_name。
- 外文名
- truncate
- 相關函數
- open,ftruncate
- 表頭文件
- #include
- 使用方法
- truncate table table_name
truncateC語言函數
表頭文件:#include <unistd.h>
定義函數:int truncate(const char *path, off_t length);
函數説明:truncate()會將參數path指定的文件大小改為參數length指定的大小。 如果原來的文件大小比參數length大,則超過的部分會被刪除
錯誤代碼:EACCESS 參數path所指定的文件無法存取
EROFS 欲寫入的文件存在於只讀文件系統內
EFAULT 參數path指針超出可存取空間
EINVAL 參數path包含不合法字符
ENAMETOOLONG 參數path太長
ENOTDIR 參數path路徑並非一目錄
EISDIR 參數path指向一目錄
ETXTBUSY 參數path所指的文件為共享程序,而且正被執行中
ELOOP 參數path有過多符號連接問題
EIO I/O存取錯誤
truncate數據庫操作
使用方法:
truncate table table_name;
操作特性:
truncate 只刪除表中的所有數據,不刪除表的結構;
truncate 語句缺省情況下將空間釋放到 minextents個 extent,除非使用reuse storage;
truncate 會將高水線復位(回到最開始)。
truncate截取字符串
smarty truncate 截取
從字符串開始處截取某長度的字符.默認是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...
- 詞條統計
-
- 瀏覽次數:次
- 編輯次數:18次歷史版本
- 最近更新: 青青的麦田year