Removes port from host config
parent
9c3964da20
commit
81287a2c95
|
@ -34,7 +34,6 @@ class Host {
|
|||
$sql = 'SELECT
|
||||
id,
|
||||
address,
|
||||
port,
|
||||
platform_id,
|
||||
name
|
||||
FROM
|
||||
|
@ -73,14 +72,13 @@ class Host {
|
|||
public function addHost($newHost) {
|
||||
try {
|
||||
$sql = 'INSERT INTO hosts
|
||||
(address, port, platform_id, name)
|
||||
(address, platform_id, name)
|
||||
VALUES
|
||||
(:address, :port, :platform_id, :name)';
|
||||
(:address, :platform_id, :name)';
|
||||
|
||||
$query = $this->db->prepare($sql);
|
||||
$query->execute([
|
||||
':address' => $newHost['address'],
|
||||
':port' => $newHost['port'],
|
||||
':platform_id' => $newHost['platform_id'],
|
||||
':name' => $newHost['name'],
|
||||
]);
|
||||
|
@ -99,25 +97,28 @@ class Host {
|
|||
* @param string $platform_id The platform ID to which the host belongs.
|
||||
* @param array $updatedHost An associative array containing the updated details of the host.
|
||||
*
|
||||
* @return bool True if the host was updated successfully, otherwise false.
|
||||
* @return bool|string True if the host was updated successfully, otherwise error message.
|
||||
*/
|
||||
public function editHost($platform_id, $updatedHost) {
|
||||
try {
|
||||
$sql = 'UPDATE hosts SET
|
||||
address = :address,
|
||||
port = :port,
|
||||
name = :name
|
||||
WHERE
|
||||
id = :id';
|
||||
id = :id AND platform_id = :platform_id';
|
||||
|
||||
$query = $this->db->prepare($sql);
|
||||
$query->execute([
|
||||
':id' => $updatedHost['id'],
|
||||
':address' => $updatedHost['address'],
|
||||
':port' => $updatedHost['port'],
|
||||
':name' => $updatedHost['name'],
|
||||
':id' => $updatedHost['id'],
|
||||
':platform_id' => $platform_id,
|
||||
':address' => $updatedHost['address'],
|
||||
':name' => $updatedHost['name']
|
||||
]);
|
||||
|
||||
if ($query->rowCount() === 0) {
|
||||
return "No host found with ID {$updatedHost['id']} in platform $platform_id";
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -86,7 +86,6 @@ CREATE TABLE IF NOT EXISTS "jilo_agents" (
|
|||
CREATE TABLE IF NOT EXISTS "hosts" (
|
||||
"id" INTEGER NOT NULL,
|
||||
"address" TEXT NOT NULL,
|
||||
"port" INTEGER NOT NULL,
|
||||
"platform_id" INTEGER NOT NULL,
|
||||
"name" TEXT,
|
||||
PRIMARY KEY("id" AUTOINCREMENT),
|
||||
|
|
|
@ -23,5 +23,6 @@ INSERT INTO jilo_agents VALUES(4,1,2,'https://meet.lindeas.com:8081','mysecretke
|
|||
INSERT INTO jilo_agents VALUES(7,1,3,'http://meet.lindeas.com:8081','mysecretkey',5);
|
||||
INSERT INTO jilo_agents VALUES(8,1,4,'http://meet.lindeas.com:8081','mysecretkey',5);
|
||||
|
||||
INSERT INTO hosts VALUES(1,'meet.lindeas.com',8888,2,'main machine');
|
||||
INSERT INTO hosts VALUES(2,'meet.example.com',9191,2,'test');
|
||||
INSERT INTO hosts VALUES(1,'meet.lindeas.com',2,'main machine');
|
||||
INSERT INTO hosts VALUES(2,'meet.example.com',2,'test');
|
||||
|
||||
|
|
Loading…
Reference in New Issue