词条 | truncate |
释义 | C语言函数相关函数:open, ftruncate 表头文件:#include <unistd.h> 定义函数: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存取错误 数据库操作的sql语句:使用方法:truncate table table_name; 操作特性:truncate 只删除表中的所有数据,不删除表的结构; truncate 是ddl操作立即生效,原数据不放到rollback segment中,不能回滚,操作不触发trigger; truncate 语句缺省情况下将空间释放到 minextents个 extent,除非使用reuse storage; truncate 会将高水线复位(回到最开始)。 smarty 截取字符串函数 truncatesmarty 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... |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。