我正在创建一个脚本,PHP
用于更新我的用户、user_personal 和 user_extra 表以MySQL
使用连接。当我使用它执行查询时,mysql_query
它返回 true,但表没有更新。
我在网上阅读过,mysql_query
如果失败则返回 false,如果MySQL
成功则返回资源,并且还读到这是PHP
.
这是有问题的查询。
UPDATE users
INNER JOIN user_personal
ON users.id = user_personal.id
INNER JOIN user_extra
ON users.id = user_extra.id
SET
users.email = '" . $user->email . "',
user_extra.life_condition = '" . $user->life_condition . "',
user_extra.keycode = '" . $user->keycode . "',
user_extra.contact_person_phone = '" . $user->contact_person_phone . "',
user_extra.doctor = '" . $user->doctor . "',
user_extra.doctor_phone = '" . $user->doctor_phone . "',
user_extra.doctorpost_phone = '" . $user->doctorpost_phone . "',
user_extra.condition = '" . $user->condition . "',
user_extra.allergy = '" . $user->allergy . "',
user_extra.goal = '" . $user->goal . "',
user_extra.attention_officer = '" . $user->attention_officer . "',
user_extra.primary_respon = '" . $user->primary_respon . "',
user_personal.name = '" . $user->name . "',
user_personal.last_name = '" . $user->last_name . "',
user_personal.insertion = '" . $user->insertion . "',
user_personal.birthdate = '" . $user->birthdate . "',
user_personal.sex = '" . $user->sex . "',
user_personal.street_name = '" . $user->street_name . "',
user_personal.house_number = '" . $user->house_number . "',
user_personal.postal_code = '" . $user->postal_code . "',
user_personal.city = '" . $user->city . "',
user_personal.country = '" . $user->country . "',
user_personal.tel_nr = '" . $user->tel_nr . "',
user_personal.contact_person = '" . $user->contact_person . "'
WHERE user_personal.name = '" . $user->name . "'
当我使用一个函数执行一个较小的查询测试版本时,INNER JOIN
该函数返回了一个资源,当我在没有连接的情况下执行查询时结果相同。我的服务器使用PHP
5.3.3 和Apache
2.2.15 版本和 MySQL 服务器 5.1.69。
你能解释一下这是怎么发生的吗?这个问题有解决方案吗?