所以这可能是一个非常愚蠢的/基本的问题,但我有一个简单的PHP函数(它可以工作),并将数据插入到PostgreSQL数据库中。
我的问题是当它遇到特定的数据时;
function insertData($pg, $csvfile)
{
$x = 0;
foreach ($csvfile as $data)
{
$email = $csvfile[$x]['email'];
$name = $csvfile[$x]['name'];
$surname = $csvfile[$x]['surname'];
$query = "INSERT INTO users (email, name, surname) VALUES ('$email', '$name', '$surname')";
$result = pg_query($pg, $query);
$x++;
}
}
当这项工作进行时,它的姓氏如下:
< Buff行情>
奥黑尔
< /块引用>
很明显,这是因为PHP代码显示为:
< Buff行情>
…values('john@example.com'、'john'、'o'hare')“;”
< /块引用>
但我不确定应该如何构造PHP以允许这样做。