CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  PHP

讨论SQLite内置函数的使用

楼主xuzuning(唠叨)2004-12-03 08:58:34 在 Web 开发 / PHP 提问

已知  
  <?php  
  $dbhandle   =   sqlite_open(':memory:');  
  $query   =   "select   datetime('now',   'localtime')";   //或  
  $query   =   "select   datetime('now')";  
   
  $ar   =   sqlite_array_query($dbhandle,   $query,SQLITE_ASSOC);  
  print_r($ar);  
  ?>  
  均可得到当前的时间。那么  
  1、函数datetime还可以有哪些参数呢?  
  2、象datetime这样的函数在SQLite中还有哪些呢?  
  问题点数:200、回复次数:13Top

1 楼zola2399(丁丁)回复于 2004-12-03 09:08:11 得分 0

帮你顶下吧Top

2 楼uGain(uGain.org)回复于 2004-12-03 09:35:49 得分 20

sqlite>   select   datetime('now');  
      2004-01-05   17:23:58   --   correct   day   and   time   of   day  
   
   
      sqlite>   select   datetime('now',   'weekday   0');  
      2004-01-11   00:00:00   --   correct   day,   lost   time   of   day  
   
   
      sqlite>   select   datetime('now',   '1   month');  
      2004-02-05   00:00:00   --   correct   day,   lost   time   of   day  
   
   
      sqlite>   select   datetime('now',   '1   year');  
      2005-01-05   00:00:00   --   correct   day,   lost   time   of   day  
   
  呵呵,正在研究。Top

3 楼uGain(uGain.org)回复于 2004-12-03 09:44:26 得分 20

http://www.sqlite.org/cvstrac/wiki?p=DateAndTimeFunctions  
   
  这个应该解决问题了.Top

4 楼xuzuning(唠叨)回复于 2004-12-03 09:51:00 得分 0

就是说datetime可以支持strtotime的参数格式?Top

5 楼ice_berg16(寻梦的稻草人)回复于 2004-12-03 09:55:49 得分 20

在官方网站上找到的资料  
   
  abs(X)   Return   the   absolute   value   of   argument   X.    
  coalesce(X,Y,...)   Return   a   copy   of   the   first   non-NULL   argument.   If   all   arguments   are   NULL   then   NULL   is   returned.   There   must   be   at   least   2   arguments.    
    glob(X,Y)   This   function   is   used   to   implement   the   "X   GLOB   Y"   syntax   of   SQLite.   The   sqlite3_create_function()   interface   can   be   used   to   override   this   function   and   thereby   change   the   operation   of   the   GLOB   operator.    
  ifnull(X,Y)   Return   a   copy   of   the   first   non-NULL   argument.   If   both   arguments   are   NULL   then   NULL   is   returned.   This   behaves   the   same   as   coalesce()   above.    
  last_insert_rowid()   Return   the   ROWID   of   the   last   row   insert   from   this   connection   to   the   database.   This   is   the   same   value   that   would   be   returned   from   the   sqlite_last_insert_rowid()   API   function.    
  length(X)   Return   the   string   length   of   X   in   characters.   If   SQLite   is   configured   to   support   UTF-8,   then   the   number   of   UTF-8   characters   is   returned,   not   the   number   of   bytes.    
    like(X,Y)   This   function   is   used   to   implement   the   "X   LIKE   Y"   syntax   of   SQL.   The   sqlite_create_function()   interface   can   be   used   to   override   this   function   and   thereby   change   the   operation   of   the   LIKE   operator.    
  lower(X)   Return   a   copy   of   string   X   will   all   characters   converted   to   lower   case.   The   C   library   tolower()   routine   is   used   for   the   conversion,   which   means   that   this   function   might   not   work   correctly   on   UTF-8   characters.    
  max(X,Y,...)   Return   the   argument   with   the   maximum   value.   Arguments   may   be   strings   in   addition   to   numbers.   The   maximum   value   is   determined   by   the   usual   sort   order.   Note   that   max()   is   a   simple   function   when   it   has   2   or   more   arguments   but   converts   to   an   aggregate   function   if   given   only   a   single   argument.    
  min(X,Y,...)   Return   the   argument   with   the   minimum   value.   Arguments   may   be   strings   in   addition   to   numbers.   The   minimum   value   is   determined   by   the   usual   sort   order.   Note   that   min()   is   a   simple   function   when   it   has   2   or   more   arguments   but   converts   to   an   aggregate   function   if   given   only   a   single   argument.    
  nullif(X,Y)   Return   the   first   argument   if   the   arguments   are   different,   otherwise   return   NULL.    
  quote(X)   This   routine   returns   a   string   which   is   the   value   of   its   argument   suitable   for   inclusion   into   another   SQL   statement.   Strings   are   surrounded   by   single-quotes   with   escapes   on   interior   quotes   as   needed.   BLOBs   are   encoded   as   hexadecimal   literals.   The   current   implementation   of   VACUUM   uses   this   function.   The   function   is   also   useful   when   writing   triggers   to   implement   undo/redo   functionality.      
  random(*)   Return   a   random   integer   between   -2147483648   and   +2147483647.    
  round(X)  
  round(X,Y)   Round   off   the   number   X   to   Y   digits   to   the   right   of   the   decimal   point.   If   the   Y   argument   is   omitted,   0   is   assumed.    
  soundex(X)   Compute   the   soundex   encoding   of   the   string   X.   The   string   "?000"   is   returned   if   the   argument   is   NULL.   This   function   is   omitted   from   SQLite   by   default.   It   is   only   available   the   -DSQLITE_SOUNDEX=1   compiler   option   is   used   when   SQLite   is   built.    
  sqlite_version(*)   Return   the   version   string   for   the   SQLite   library   that   is   running.   Example:   "2.8.0"    
  substr(X,Y,Z)   Return   a   substring   of   input   string   X   that   begins   with   the   Y-th   character   and   which   is   Z   characters   long.   The   left-most   character   of   X   is   number   1.   If   Y   is   negative   the   the   first   character   of   the   substring   is   found   by   counting   from   the   right   rather   than   the   left.   If   SQLite   is   configured   to   support   UTF-8,   then   characters   indices   refer   to   actual   UTF-8   characters,   not   bytes.    
  typeof(X)   Return   the   type   of   the   expression   X.   The   only   return   values   are   "null",   "integer",   "real",   "text",   and   "blob".   SQLite's   type   handling   is   explained   in   Datatypes   in   SQLite   Version   3.    
  upper(X)   Return   a   copy   of   input   string   X   converted   to   all   upper-case   letters.   The   implementation   of   this   function   uses   the   C   library   routine   toupper()   which   means   it   may   not   work   correctly   on   UTF-8   strings.    
   
  avg(X)   Return   the   average   value   of   all   X   within   a   group.    
  count(X)  
  count(*)   The   first   form   return   a   count   of   the   number   of   times   that   X   is   not   NULL   in   a   group.   The   second   form   (with   no   argument)   returns   the   total   number   of   rows   in   the   group.    
  sum(X)   Return   the   numeric   sum   of   all   values   in   the   group.    
  Top

6 楼uGain(uGain.org)回复于 2004-12-03 10:02:45 得分 20

The   strftime()   function   also   takes   a   format   string   as   its   first   argument.    
   
  支持strftime();  
   
  select   strftime('%Y-%m-%d',   'now');Top

7 楼uGain(uGain.org)回复于 2004-12-03 10:07:45 得分 20

呵呵,这玩意现在连本全面的手册都没有,资料都要到cvs里去找。  
   
  Top

8 楼surfchen(冲浪)回复于 2004-12-03 10:15:19 得分 20

一个strftime搞完...呵呵Top

9 楼fzjw(冰凌尘埃)回复于 2004-12-03 10:20:48 得分 20

呵呵,下载了SQLite   3,感觉这个数据库系统比较弱,也许是了解不多的原因。手册都不全,好多东西找不到,郁闷Top

10 楼ezdevelop(phpsalon.com)回复于 2004-12-03 10:28:52 得分 20

http://blog.csdn.net/ezdevelop/archive/2004/09/21/111666.aspx  
   
  在PHP中,可以将所有的函数作为SQLite的函数来使用  
  例如使用md5()  
  SELECT   php('md5',   filename)   from   filesTop

11 楼surfchen(冲浪)回复于 2004-12-06 00:21:30 得分 20

题外话  
  SQLite没有show   tables?show   tables有时候用起来蛮方便的嘛...Top

12 楼xuzuning(唠叨)回复于 2004-12-06 08:18:48 得分 0

没有!但SQLite有一张内部表——sqlite_master  
  当select   *   from   sqlite_master时就可得到全部表信息Top

13 楼uGain(uGain.org)回复于 2004-12-06 09:04:00 得分 20

直接用.tables命令。Top

相关问题

  • 讨论在BCB中使用API函数的问题。 (送分? 可以赊帐吗?
  • 讨论:拷贝构造函数的使用(与内存分配有关)
  • 函数的使用?
  • 讨论:如何写函数
  • 构造函数再讨论
  • -_-_-_-_-_-_-相似函数的讨论_-_-_-_-_-_-_-_-_
  • 怎样使用SHGetDesktopFolder 函数?
  • 如何使用RegCreateKeyEx函数?
  • 怎样使用TextOut()函数
  • SHBrowseForFolder()函数如何使用?

关键词

  • 函数
  • null
  • sqlite
  • glob
  • datetime
  • arguments
  • correct
  • day
  • 使用
  • rowid

得分解答快速导航

  • 帖主:xuzuning
  • uGain
  • uGain
  • ice_berg16
  • uGain
  • uGain
  • surfchen
  • fzjw
  • ezdevelop
  • surfchen
  • uGain

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo