gpt4 book ai didi

php - 从 php 运行 mysql 查询

转载 作者:行者123 更新时间:2023-11-29 00:23:14 24 4
gpt4 key购买 nike

我正在尝试从这样的 PHP 脚本运行 MySQL 查询:

$q = "
UPDATE
cf_ab_companies, inndata200
SET
cf_ab_companies.col_158 = inndata200.AFakt_10_Fast_renhold,
cf_ab_companies.col_159 = IF ( inndata200.Startdato = "01.01.3000 00:00" OR inndata200.Startdato = "01.01.2000 00:00", NULL, str_to_date(inndata200.Startdato, '%d.%m.%Y')),
cf_ab_companies.col_160 = IF ( inndata200.Sluttdato = "01.01.3000 00:00" OR inndata200.Sluttdato = "01.01.2000 00:00", NULL, str_to_date(inndata200.Sluttdato, '%d.%m.%Y'))
WHERE
cf_ab_companies.model_id = inndata200.ImportGOID;";

mysql_query($q, $db);

但是查询似乎没有正确存储在 PHP 中。在 PHP 中存储这样的查询的最简单方法是什么?

感谢大家的帮助

最佳答案

这应该使它工作;在引号 (") 之前加上斜杠 (\),因为它会让人混淆:

$q = "
UPDATE
cf_ab_companies, inndata200
SET
cf_ab_companies.col_158 = inndata200.AFakt_10_Fast_renhold,
cf_ab_companies.col_159 = IF ( inndata200.Startdato = \"01.01.3000 00:00\" OR inndata200.Startdato = \"01.01.2000 00:00\", NULL, str_to_date(inndata200.Startdato, '%d.%m.%Y')),
cf_ab_companies.col_160 = IF ( inndata200.Sluttdato = \"01.01.3000 00:00\" OR inndata200.Sluttdato = \"01.01.2000 00:00\", NULL, str_to_date(inndata200.Sluttdato, '%d.%m.%Y'))
WHERE
cf_ab_companies.model_id = inndata200.ImportGOID;";

关于php - 从 php 运行 mysql 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20268676/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com