Removes port from host config
parent
9c3964da20
commit
81287a2c95
|
@ -34,7 +34,6 @@ class Host {
|
||||||
$sql = 'SELECT
|
$sql = 'SELECT
|
||||||
id,
|
id,
|
||||||
address,
|
address,
|
||||||
port,
|
|
||||||
platform_id,
|
platform_id,
|
||||||
name
|
name
|
||||||
FROM
|
FROM
|
||||||
|
@ -73,14 +72,13 @@ class Host {
|
||||||
public function addHost($newHost) {
|
public function addHost($newHost) {
|
||||||
try {
|
try {
|
||||||
$sql = 'INSERT INTO hosts
|
$sql = 'INSERT INTO hosts
|
||||||
(address, port, platform_id, name)
|
(address, platform_id, name)
|
||||||
VALUES
|
VALUES
|
||||||
(:address, :port, :platform_id, :name)';
|
(:address, :platform_id, :name)';
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
$query->execute([
|
$query->execute([
|
||||||
':address' => $newHost['address'],
|
':address' => $newHost['address'],
|
||||||
':port' => $newHost['port'],
|
|
||||||
':platform_id' => $newHost['platform_id'],
|
':platform_id' => $newHost['platform_id'],
|
||||||
':name' => $newHost['name'],
|
':name' => $newHost['name'],
|
||||||
]);
|
]);
|
||||||
|
@ -99,25 +97,28 @@ class Host {
|
||||||
* @param string $platform_id The platform ID to which the host belongs.
|
* @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.
|
* @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) {
|
public function editHost($platform_id, $updatedHost) {
|
||||||
try {
|
try {
|
||||||
$sql = 'UPDATE hosts SET
|
$sql = 'UPDATE hosts SET
|
||||||
address = :address,
|
address = :address,
|
||||||
port = :port,
|
|
||||||
name = :name
|
name = :name
|
||||||
WHERE
|
WHERE
|
||||||
id = :id';
|
id = :id AND platform_id = :platform_id';
|
||||||
|
|
||||||
$query = $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
$query->execute([
|
$query->execute([
|
||||||
':id' => $updatedHost['id'],
|
':id' => $updatedHost['id'],
|
||||||
':address' => $updatedHost['address'],
|
':platform_id' => $platform_id,
|
||||||
':port' => $updatedHost['port'],
|
':address' => $updatedHost['address'],
|
||||||
':name' => $updatedHost['name'],
|
':name' => $updatedHost['name']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($query->rowCount() === 0) {
|
||||||
|
return "No host found with ID {$updatedHost['id']} in platform $platform_id";
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
|
@ -86,7 +86,6 @@ CREATE TABLE IF NOT EXISTS "jilo_agents" (
|
||||||
CREATE TABLE IF NOT EXISTS "hosts" (
|
CREATE TABLE IF NOT EXISTS "hosts" (
|
||||||
"id" INTEGER NOT NULL,
|
"id" INTEGER NOT NULL,
|
||||||
"address" TEXT NOT NULL,
|
"address" TEXT NOT NULL,
|
||||||
"port" INTEGER NOT NULL,
|
|
||||||
"platform_id" INTEGER NOT NULL,
|
"platform_id" INTEGER NOT NULL,
|
||||||
"name" TEXT,
|
"name" TEXT,
|
||||||
PRIMARY KEY("id" AUTOINCREMENT),
|
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(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 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(1,'meet.lindeas.com',2,'main machine');
|
||||||
INSERT INTO hosts VALUES(2,'meet.example.com',9191,2,'test');
|
INSERT INTO hosts VALUES(2,'meet.example.com',2,'test');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue