Возник вопрос по обновлению данных в двух таблицах, вот функция
public function save($task_id) {
if ($this->id) {
$sql = 'update phones set phone=\''.$this->phone.'\', data=\'\', '.
'reply=\''.$this->reply.'\', duration=\''.$this->duration.'\', status=\''.$this->status.'\' '.
'where id=\''.$this->id.'\'';
$result = DB::query(Database::UPDATE, $sql)->execute();
if ($result) {
$result = $this->id;
} else {
$result = false;
}
} else {
$sql = 'insert into phones(task_id, date, phone, data, reply, duration, status) values('.
'\''.$task_id.'\', '.
'\''.$this->date.'\', '.
'\''.$this->phone.'\', '.
'\'\', '.
'\''.$this->reply.'\', '.
'\''.$this->duration.'\', '.
'\''.$this->status.'\' '.
')';
$result = DB::query(Database::INSERT, $sql)->execute();
if ($result) {
list($id, $rows) = $result;
$this->id = (int)$id;
$result = $this->id;
} else {
$result = false;
}
}
return ($result);
}
Необходимо чтобы поля task_id, data, reply, status также апдейтились в таблице billing. Помогите пожалуйста исправить функцию
Написал функцию
public function save($task_id) {
if ($this->id) {
$sql = 'update phones set phone=\''.$this->phone.'\', data=\'\', '.
'reply=\''.$this->reply.'\', duration=\''.$this->duration.'\', status=\''.$this->status.'\' '.
'where id=\''.$this->id.'\'';
$sqlbill = 'update billing set data=\'\', '. 'reply=\''.$this->reply.'\', status=\''.$this->status.'\' '.'where dst=\''.$phone'\'';
$result = DB::query(Database::UPDATE, $sql, $sqlbill)->execute();
if ($result) {
$result = $this->id;
} else {
$result = false;
}
} else {
$sql = 'insert into phones(task_id, date, phone, data, reply, duration, status) values('.
'\''.$task_id.'\', '.
'\''.$this->date.'\', '.
'\''.$this->phone.'\', '.
'\'\', '.
'\''.$this->reply.'\', '.
'\''.$this->duration.'\', '.
'\''.$this->status.'\' '.
')';
$sqlbill = 'insert into billing(task_id, data, reply, status) values('.
'\''.$task_id.'\', '.
'\'\', '.
'\''.$this->reply.'\', '.
'\''.$this->status.'\' '.
')';
$result = DB::query(Database::INSERT, $sql, $sqlbill)->execute();
if ($result) {
list($id, $rows) = $result;
$this->id = (int)$id;
$result = $this->id;
} else {
$result = false;
}
}
return ($result);
}
Сборка персонального компьютера от Artline: умный выбор для современных пользователей