获取列默认值,因为它们是结果集的一行 [英] get columns default values as they are a row of a resultset

查看:57
本文介绍了获取列默认值,因为它们是结果集的一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以获取列的默认值,因为它们是结果集的一行?

is there a way to get default values of columns as they are a row of a resultset?

`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`state` tinyint(2) NOT NULL DEFAULT '22',
`pubdate` datetime NOT NULL DEFAULT '2012-01-01 00:00:00',

例如,像这样的表应返回以下记录:

for instance a table like this should return this record:

id->NULL (?)
state->22
pubdate->2012-01-01 00:00:00

实际上,当某些用户打开edit.php?id = 44时,他将获得第44行(更新模式),但是如果他打开edit.php?id = 0(插入模式),我希望这些字段包含默认值占位符的值

in practice, when some user opens edit.php?id=44 he will get the row 44 (update mode), but if he opens edit.php?id=0 (insert mode) I want that the fields contain default values as place holders

先谢谢您

推荐答案

有一个通过上述查询,您似乎需要在表中至少包含一条记录,因为否则它不返回任何记录.对于当前时间戳,它将返回时间戳格式的字符串0s.

With above query, it seems that you need to have atleast one record in the table as it returns no records otherwise. For current timestamp, it return a timestamp formatted string of 0s.

这篇关于获取列默认值,因为它们是结果集的一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆