/ LJCPHPCodeDoc / LJCDBAccessLib / LJCDbAccess / GetValue


Parameters
$row - The data row columns.
$columnName - The column name.

Returns

The data value if the element exists; otherwise null.

Syntax

PHP
public static function GetValue(?array $row, string $columnName)

Returns a data value if the element exists.

Example

PHP
 // Returns a data value if the element exists.
 private static function GetValue(LJCConnectionValues $connectionValues)
 {
   // See constructor for how to create $connectionValues.
   $dbAccess = new LJCDbAccess($connectionValues);
 
   $tableName = "TableName";
   $sql = "select ID, Name from {$tableName} where ID = 1";
   $row = $dbAccess->Retrieve($sql);
   $id = LJCDbAccess::GetValue($row, "ID");
   $name = LJCDbAccess::GetValue($row, "Name");
   $result = "{$id}, {$name}";
 
   // result:
   // 1, Name
 }

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.