dp13668681869 2014-01-06 10:49
浏览 29

有没有一种自动化方法可以在MySQLI预处理语句中生成变量类型参数?

I am now fully comfortable with writing MySQLi prepared statements and binding variables like in the code below:

$stmt->bind_param('ssssi',$this->OrderNumber,$this->Comment,$this->Code,$this->Amount,$this->TransDate,$this->FirstCollectionDate,$this->FileName,$id);

The thing is, I am now updating some code in a script which generates a database class for all the tables in my system. With methods such as Get, Save, Delete etc. etc.

I have a foreach loop generating each column name for the second half of the bind_param() function, but I'm going to need my foreach loop to also generate whether it's a string, integer, decemal etc.

Is there a function where I check the variable itself to see what type it is? And therefore check if it's either s,d,i or b. Then I can generate a string of letters for the first half of the bind_param() function.

It's the most annoying part of MySQLi, this variable type setting!

* EDIT * This chap believes setting always to string ('s') works and letting the behind the scenes do the work? https://stackoverflow.com/a/14370546/900559

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向