truncate()

来源:互联网 发布:淘宝所有订单不全 编辑:程序博客网 时间:2024/06/15 11:59


truncate指的是一种语言函数。
外文名
truncate
相关函数
open, ftruncate
表头文件
#include <unistd.h>
使用方法
truncate table table_name

目录

  1. 1C语言函数
  2. 2数据库操作的sql语句:
  3. 使用方法:
  1. 操作特性:
  2. 3smarty 截取字符串函数 truncate
  1. smarty truncate 截取
  2. 例 截取:
  3. 输出结果:

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 截取字符串函数 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...
0 0
原创粉丝点击