PDO PARAM_STR和长度 [英] PDO PARAM_STR and length

查看:85
本文介绍了PDO PARAM_STR和长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不理解PDO PARAM_*语句中的length选项.

I don't understand the length option in a PDO PARAM_* statement.

长度是否表示必需的字符数,或者是最大字符数?

Does the length indicate an amount of required characters, or is it a max?

示例:

$sth->bindParam(2, $color, PDO::PARAM_STR, 12);

这是否需要12个字符,还是将其限制为12个字符?还是我完全误解了这是怎么回事?

Does this require 12 characters, or is this limiting it to 12 characters? Or, am I completely misunderstanding what this is doing?

推荐答案

这表明您希望在输出参数中接收多少数据,服务器将不会发送更多数据.

It's an indication of how how much data you wish to receive in the output parameter, the server will not send more than this.

因此,要回答您的问题,这是一个限制,而不是一个要求.

So, to answer your question, it's a limitation rather than a requirement.

这篇关于PDO PARAM_STR和长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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