03-18-2023, 06:10 PM
That's I'll check that out.
This is the version I have. Does it match up with yours?
PHP 7.3.31-1~deb10u1 (cli) (built: Oct 24 2021 15:18:08) ( NTS )
100% those queries were working for a lot of people including myself as some of them have been there basically from day 1. It's obvious just from forum posts, guaranteed people using it didn't make all the changes you did. I'm really hoping I can find out why this is the case, I'm hoping you have a different PHP version but if you used my install script then I can't see how yours would be different.
What do you think of this updated php code vs what I'm currently doing?
Switched from mysqli to PDO to access the database, using prepared statement so it's safer, try catch block and error handling.
This file is the new dcGetPorts.php
This is the version I have. Does it match up with yours?
PHP 7.3.31-1~deb10u1 (cli) (built: Oct 24 2021 15:18:08) ( NTS )
100% those queries were working for a lot of people including myself as some of them have been there basically from day 1. It's obvious just from forum posts, guaranteed people using it didn't make all the changes you did. I'm really hoping I can find out why this is the case, I'm hoping you have a different PHP version but if you used my install script then I can't see how yours would be different.
What do you think of this updated php code vs what I'm currently doing?
Switched from mysqli to PDO to access the database, using prepared statement so it's safer, try catch block and error handling.
This file is the new dcGetPorts.php
PHP Code:
<?php
header('Content-Type: application/json');
header("Access-Control-Allow-Origin: *");
try {
require '../php/database.php';
$query = "SELECT `dcSortID` FROM `systemSettings` WHERE `userID` = 1";
$stmt = $pdo->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$sortID = $row['dcSortID'];
if ($sortID == 1) {
$s = "name";
} else if ($sortID == 2) {
$s = "iconID";
} else if ($sortID == 3) {
$s = "gpio";
}
$query = "SELECT `pinID`, `gpio`, `assigned`, `name`, `iconID`, `invert`, `manual` FROM `pinsAvailable` WHERE `pinTypeID` = 2 AND `assigned` = 1 ORDER BY `$s` ASC";
$stmt = $pdo->prepare($query);
$stmt->execute();
$dataWindow = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($dataWindow);
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
$pdo = null;