Skip to content

Commit

Permalink
QB value method; Request isset method
Browse files Browse the repository at this point in the history
  • Loading branch information
donwilson committed Nov 7, 2023
1 parent 90bb520 commit 72f8691
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Magnetar/Database/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ public function fetchVar(string|int $column_key=0): string|int|false {
return $this->adapter->get_var($query, $params, $column_key);
}


/**
* Alias for fetchVar()
* @param string|int $column_key The column to use as the array key for the results. If empty, fetches the first column
* @return string|int|false
*/
public function value(string|int $column_key=0): string|int|false {
return $this->fetchVar($column_key);
}

/**
* Count the number of rows matching the query
* @return int
Expand Down
9 changes: 9 additions & 0 deletions src/Magnetar/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ public function get(string $name, mixed $default=null): mixed {
return $this->parameter($name, $default);
}

/**
* Determine if a parameter exists
* @param string $name The name of the parameter to check
* @return bool True if the parameter exists, false otherwise
*/
public function isset(string $name): bool {
return isset($this->parameters[ $name ]);
}

/**
* Get all parameters from the request
* @return array
Expand Down

0 comments on commit 72f8691

Please sign in to comment.