Php PDO/MySQL以e(指数)为整数保存数字字符串
我正在尝试将以下字符串保存到数据库:Php PDO/MySQL以e(指数)为整数保存数字字符串,php,mysql,pdo,integer,exponent,Php,Mysql,Pdo,Integer,Exponent,我正在尝试将以下字符串保存到数据库:12E2。由于E(指数),MySQL将其保存为“1200”(12×102)。有没有办法避免这种情况?我正试图将其保存到数据库中的VARCHAR字段中 $q->bindValue(":field","12E2",PDO::PARAM_STR); 编辑:我上传了这个案例。该脚本使用以下代码: $fetchQuery=$db->prepare("SELECT `strLocatieNr` FROM `tblShopProducten` WHERE `i
12E2
。由于E
(指数),MySQL将其保存为“1200”(12×102)。有没有办法避免这种情况?我正试图将其保存到数据库中的VARCHAR
字段中
$q->bindValue(":field","12E2",PDO::PARAM_STR);
编辑:我上传了这个案例。该脚本使用以下代码:
$fetchQuery=$db->prepare("SELECT `strLocatieNr` FROM `tblShopProducten` WHERE `intID`=254");
$fetchQuery->execute();
$fetchData=$fetchQuery->fetch();
echo "Old: ".$fetchData["strLocatieNr"]."<br />";
$updateValue=@$_GET["value"];
echo "Update value: ";
var_dump($updateValue);
echo "<br />";
$q=$db->prepare("UPDATE `tblShopProducten` SET `strLocatieNr`=:field WHERE `intID`=254");
$q->bindValue(":field",$updateValue,PDO::PARAM_STR);
$q->execute();
echo "Rows affected: ".$q->rowCount()."<br />";
$fetchQuery->execute();
$fetchData=$fetchQuery->fetch();
echo "New: ".$fetchData["strLocatieNr"];
$fetchQuery=$db->prepare(“从`tblShopProducten`中选择`strlocatener`,其中`intID`=254”);
$fetchQuery->execute();
$fetchData=$fetchQuery->fetch();
echo“Old:”.$fetchData[“strlocatener”]。“
”;
$updateValue=@$_GET[“value”];
echo“更新值:”;
变量转储($updateValue);
回声“
”;
$q=$db->prepare(“更新`tblShopProducten`SET`strlocatener`=:其中`intID`=254的字段”);
$q->bindValue(“:field“,$updateValue,PDO::PARAM_STR);
$q->execute();
回显“受影响的行:”..q->rowCount()。“
”;
$fetchQuery->execute();
$fetchData=$fetchQuery->fetch();
echo“New:”.$fetchData[“strlocatener”];
奇怪,我无法复制它。您确定数据库中的字段类型是varchar(x),其中x是字符串的最大期望长度吗
或者,您确定实际代码中的绑定值被引号括起来了吗
如果什么都不管用,我会试试看
$q->bindValue(":field",(string)"12E2",PDO::PARAM_STR);
MySQL中的列类型是什么?我无法复制this@Jules你能提供更多的代码吗?我也不能用
VARCHAR
字段(使用INT
我得到了预期的结果)来重现这一点。我用扩展示例编辑了原始问题。