我正在使用RedBeanPHP,我有一串数字,是否可以像字符串一样存储它,而不是 double 类型?我的例子是下一个,但它不起作用:
$participant = R::dispense('participants');
$participant->setMeta("participants.number","string");
$participant->number = $number;
R::store($participant);
最佳答案
Redbean 检查属性给定值以设置列的正确类型,我建议您每次都关闭卡住选项,但是,当您需要更改某些内容时,只需将其打开即可。我的意思是,当您确实需要在表上执行一些更改时,只需打开卡住,例如:
// the false param will disable db changes
R::setup('dns', 'user', 'pass', false);changes (freeze option)
//...
//... let's imagine you have some code here
//...
R::freeze(false);
$participant = R::dispense('participants');
$participant->number = 'intert any string'; // need to set field to string type
R::store($participant);
R::freeze(true);
$participant->number = '99.99';
R::store($participant);
我知道这不是最好的事情,但是当您需要更改数据库结构上的某些内容时,您只需打开它即可。本质上,在生产环境中您应该始终将其关闭
关于php - 如何更改 redbeanphp 中的列类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42174048/