AutoPulse v 1.0.1
 
Loading...
Searching...
No Matches
C:/Users/ivans/OneDrive/Документы/ZWA/sem/get_models.php File Reference

This script retrieves the values of the 'model' column of the 'models' table according to 'make' parameter of the GET request and sends them back as .json response. More...

Variables

 if (!isset( $_GET[ 'make'])||empty( $_GET[ 'make']))
 
if(isset($error) && $error==="db_access_failed") try
 
 $models = []
 
 while ( $row=$stmt->fetch(PDO::FETCH_ASSOC))
 

Detailed Description

This script retrieves the values of the 'model' column of the 'models' table according to 'make' parameter of the GET request and sends them back as .json response.

Variable Documentation

◆ $models

$models = []

◆ if

if(!isset($_GET['make'])||empty($_GET['make'])) ( ! isset $_GET[ 'make'])||empty( $_GET[ 'make'])

Checks if the 'make' parameter is provided in the request. If not, returns an empty JSON array and exits the script.

◆ try

if (isset( $error) &&$error==="db_access_failed") try
Initial value:
{
$stmt = $pdo->prepare('SELECT DISTINCT model FROM models WHERE make = :make')
if(! $user) catch(PDOException $e) $pdo
Definition myprofile.php:59
if(! $userExists) $stmt
Definition process-accountDelete.php:48

Checks for a database access error and terminates the script if it occurs.

◆ while

while($row=$stmt->fetch(PDO::FETCH_ASSOC)) ( $row = $stmt->fetch(PDO::FETCH_ASSOC))

Loops through the query results and collects distinct models into an array. Encodes the collected models as a JSON array and outputs it.