mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
Use correct phone for response to discussion
This commit is contained in:
parent
c4bc7d94c1
commit
aee9fc847f
7 changed files with 104 additions and 6 deletions
|
@ -388,4 +388,31 @@ namespace models;
|
|||
|
||||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find destination of last received message for an origin and user
|
||||
* @param int $id_user : User id
|
||||
* @param string $origin : Origin number
|
||||
* @return array
|
||||
*/
|
||||
public function get_last_for_origin_and_user (int $id_user, string $origin)
|
||||
{
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM received
|
||||
WHERE origin = :origin
|
||||
AND destination IN (SELECT number FROM phone WHERE id_user = :id_user)
|
||||
ORDER BY at DESC
|
||||
LIMIT 0,1
|
||||
";
|
||||
|
||||
$params = [
|
||||
'origin' => $origin,
|
||||
'id_user' => $id_user,
|
||||
];
|
||||
|
||||
$result = $this->_run_query($query, $params);
|
||||
|
||||
return ($result[0] ?? []);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,5 +300,33 @@ namespace models;
|
|||
|
||||
return $this->_run_query($query, $params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find last sended message for a destination and user
|
||||
* @param int $id_user : User id
|
||||
* @param string $destination : Destination number
|
||||
* @return array
|
||||
*/
|
||||
public function get_last_for_destination_and_user (int $id_user, string $destination)
|
||||
{
|
||||
$query = "
|
||||
SELECT *
|
||||
FROM sended
|
||||
WHERE destination = :destination
|
||||
AND origin IN (SELECT number FROM phone WHERE id_user = :id_user)
|
||||
ORDER BY at DESC
|
||||
LIMIT 0,1
|
||||
";
|
||||
|
||||
$params = [
|
||||
'destination' => $destination,
|
||||
'id_user' => $id_user,
|
||||
];
|
||||
|
||||
$result = $this->_run_query($query, $params);
|
||||
|
||||
return ($result[0] ?? []);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue