按月存档:2007年7月

PHP-MySQL:获得最后插入的 ID

MySQL 中有自增列,那如何获得插入语句生成的自增列 ID 呢?

在 MySQL 中用 last_insert_id() 函数;

在 PHP 中用 mysql_insert_id() 函数。

  • 0 评论
  • 分类: MySQL, PHP
  • HTML 编辑器:FCKeditor

    FCKeditor HOME

    最近需要一个 online HTML text editor,搜了一下,找到了 FCKeditor,看了一下,原来 Intervals 用的就是他,一看他们的用户名单,不得了,Adobe、Oracle等等等等都在列啊。

    FCKeditor Demo

    功能不必多说了,肯定是超强了,支持 JAVA、PHP、ASP.NET、ASP等等,在PHP下使用也很简单:

    1、下载解压到网站的一目录,如:/fckeditor/;

    2、写以下的 PHP 代码:

    <?php

    include(’/fckeditor/fckeditor.php’);

    $editor = new FCKeditor (’news_content’); // 参数为 FORM 要 POST 的 Name;

    $editor->BasePath = ‘/fckeditor/’; // FCKeditor 的安装路径;

    $editor->Value = ”; // 缺省值;

    $editor->Width = ‘100%’;

    $editor->Height = ‘500′;

    $editor->Create();

    ?>

    如此简单!

  • 3 评论
  • 分类: PHP
  • 让 MySQL 的 TimeStamp 列不要自动更新

    MySQL 有一种 timestamp 列类型,可以自动为该列插入当前时间戳,当 Update 语句执行时,该时间戳也会自动更新。但有的时候,并不希望在更新时该值也自动更新,那该怎么办呢?

    其实也很简单,timestamp 自身支持这种设置。

    当建立 timestamp 列时,一般的语句为:

    create table tablename ( datecolname timestamp not null , ……..)

    其实该语句的完整语句为:

    create table tablename (datecolname timestamp not null default current_timestamp on update current_timetamp, ……..)

    如果你想让行值发生变化时时间戳不要自动更新,可以使用以下语句:

    create table tablename(datecolname timestamp not null default current_timestamp, ……..)

    问题的关键就在于有 default current_timestamp 语句而没有 on update current_timestamp 语句。

    在 MySQL Query Browser 中建立表结构时,如果不想让 timestamp 自动更新,记得一定要手动输入 default 为 current_timestamp ,这样 MySQL Query Browser 就会自动生成合适的 SQL 语句来建立表结构了。

  • 0 评论
  • 分类: MySQL
  • 链接


    存档


    管理


    广告