public getValue ( string $tableName, string $column, integer $limit = 1 ) : mixed | ||
$tableName | string | The name of the database table to work with. |
$column | string | The desired column |
$limit | integer | Limit of rows to select. Use null for unlimited..1 by default |
리턴 | mixed | Contains the value of a returned column / array of values |
public function getValue($tableName, $column, $limit = 1)
{
$res = $this->ArrayBuilder()->get($tableName, $limit, "{$column} AS retval");
if (!$res) {
return null;
}
if ($limit == 1) {
if (isset($res[0]["retval"])) {
return $res[0]["retval"];
}
return null;
}
$newRes = array();
for ($i = 0; $i < $this->count; $i++) {
$newRes[] = $res[$i]['retval'];
}
return $newRes;
}
/** * Function to get a total records count * * @return int */ private function count() { $res = $this->db->getValue($this->dbTable, "count(*)"); return $res['cnt']; }