src/db/DbTable.php
public static function select($db, $tableName, $colNames, $id)
    {
        $cols = array_map(
            function ($colName) {
                return Db::quote($colName);
            },
            $colNames
        );

        $sql = "select " . implode($cols, ", ") .
          " from " . Db::quote($tableName) . " where id = ?";
        return $db->query($sql, [$id]);
    }
public static function select($db, $tableName, $colNames, $id)
    {
        $cols = array_map(
            function ($colName) {
                return Db::quote($colName);
            },
            $colNames
        );

        $sql = "select " . implode($cols, ", ") .
          " from " . Db::quote($tableName) . " where id = ?";
        return $db->query($sql, [$id]);
    }
public static function select ( $ db , $ tableName , $ colNames , $ id ) { $ cols = array_map ( function ( $ colName ) { return Db :: quote ( $ colName ) ; } , $ colNames ) ; $ sql = "select " . implode ( $ cols , ", " ) . " from " . Db :: quote ( $ tableName ) . " where id = ?" ; return $ db -> query ( $ sql , [ $ id ] ) ; }
Selects a record from a table.

For example:

list(
$username,
$password
) = DbTable::select($db, "user", ["username", "password"], 1);

@param DbConnector $db        Database connection
@param string      $tableName Table name
@param string[]    $colNames  Column names
@param string      $id        Record ID

@return mixed[]
Selects a record from a table .