Commit 19258c13 authored by MBoretto's avatar MBoretto

renaming data in notes

parent e4483deb
......@@ -102,8 +102,8 @@ class Conversation
return false;
}
//Load the conversation data
$this->protected_notes = json_decode($this->conversation['data'], true);
//Load the conversation notes
$this->protected_notes = json_decode($this->conversation['notes'], true);
$this->notes = $this->protected_notes;
}
......@@ -179,7 +179,7 @@ class Conversation
'chat_id' => $this->chat_id,
];
if (ConversationDB::updateConversation($fields, $where)) {
//Reload the data
//Reload the notes
$this->load();
return true;
}
......@@ -191,21 +191,19 @@ class Conversation
/**
* Store the array/variable in the database with json_encode() function
*
* @param array $data
*
* @return bool
*/
public function update()
{
if ($this->exists()) {
$fields = ['data' => json_encode($this->notes)];
$fields = ['notes' => json_encode($this->notes)];
$where = [
'status' => 'active',
'user_id' => $this->user_id,
'chat_id' => $this->chat_id,
];
if (ConversationDB::updateConversation($fields, $where)) {
//Reload the data
//Reload the notes
$this->load();
return true;
}
......@@ -227,7 +225,7 @@ class Conversation
}
/**
* Retrieve the data stored in the conversation
* Retrieve the notes stored in the conversation
*
* @return array|null
*/
......
......@@ -87,22 +87,22 @@ class ConversationDB extends DB
try {
$sth = self::$pdo->prepare('INSERT INTO `' . TB_CONVERSATION . '`
(
`status`, `user_id`, `chat_id`, `command`, `data`, `created_at`, `updated_at`
`status`, `user_id`, `chat_id`, `command`, `notes`, `created_at`, `updated_at`
)
VALUES (
:status, :user_id, :chat_id, :command, :data, :date, :date
:status, :user_id, :chat_id, :command, :notes, :date, :date
)
');
$active = 'active';
//$data = json_encode('');
$data = '""';
//$notes = json_encode('');
$notes = '""';
$created_at = self::getTimestamp();
$sth->bindParam(':status', $active);
$sth->bindParam(':command', $command);
$sth->bindParam(':user_id', $user_id);
$sth->bindParam(':chat_id', $chat_id);
$sth->bindParam(':data', $data);
$sth->bindParam(':notes', $notes);
$sth->bindParam(':date', $created_at);
$status = $sth->execute();
......
......@@ -141,7 +141,7 @@ CREATE TABLE IF NOT EXISTS `conversation` (
`chat_id` bigint NULL DEFAULT NULL COMMENT 'Telegram chat_id can be a the user id or the chat id ',
`status` ENUM('active', 'cancelled', 'stopped') NOT NULL DEFAULT 'active' COMMENT 'active conversation is active, cancelled conversation has been truncated before end, stopped conversation has end',
`command` varchar(160) DEFAULT '' COMMENT 'Default Command to execute',
`data` varchar(1000) DEFAULT 'NULL' COMMENT 'Data stored from command',
`notes` varchar(1000) DEFAULT 'NULL' COMMENT 'Data stored from command',
`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment