Skip to content

Commit

Permalink
db updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vzuburlis committed Sep 28, 2022
1 parent 6f4f490 commit 76f25c0
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
3 changes: 0 additions & 3 deletions source/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ You can create a new database backup and then download it or restore(Load) it la

This option will display the settings of the php moduls on the server. This is for informational purposes only. DO NOT share screenshots in the public of this page as it includes data about the server configuration.

## /admin/sql

In this page you can review your database, only administrators have access.

## /admin/content

Expand Down
47 changes: 42 additions & 5 deletions source/api-db.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ $result = $db->get("SELECT title,author FROM post;");
```


### getAssoc ()
Runs a query and returns the results as an associative array.

**Parameters**
- $q:string The query.
- $args:array (optional) Values to prepare the statement.


### gen ()
Runs a query and returns a generator that yields the rows.

Expand All @@ -47,6 +55,21 @@ $generator = $db->gen("SELECT title,author FROM post;");
```


### getOne ()
Runs a query and returns the first result as an array.

**Parameters**
- $q:string The query.
- $args:array (optional) Values to prepare the statement.

Example:
```
$result = $db->get("SELECT title,author FROM post;");
// Returns
[0=>'Lorem ipsum', 'title'=>'Lorem ipsum', 1=>'John', 'author'=>'John']
```


### getRows ()
Runs a query and returns the results as an array. With rows fetched with mysqli_fetch_row().

Expand All @@ -65,6 +88,21 @@ $result = $db->get("SELECT title,author FROM post;");
```


### value ()
Runs a query and returns the value of the first column of the first row of the results.

**Parameters**
- $q:string The query.
- $args:array (optional) Values to prepare the statement.

Example:
```
$res = $db->get("SELECT title FROM post WHERE id=1;");
// returns
'Lorem ipsum'
```


### getList ()
Runs a query and returns an array with the values of the first columns from the results.

Expand All @@ -80,19 +118,18 @@ $titles = $db->get("SELECT title,author FROM post;");
```


### value ()
Runs a query and returns the value of the first column of the first row of the results.
### getOptions ()
Returns an associative array using the first column as keys, and the second column as values.

**Parameters**
- $q:string The query.
- $args:array (optional) Values to prepare the statement.

Example:
```
$res = $db->get("SELECT title FROM post WHERE id=1;");
$res = $db->get("SELECT id, title FROM post;");
// returns
'Lorem ipsum'
```
[1=>'Lorem ipsum', 2=>'Lorem ipsum2']
### error ()
Expand Down
18 changes: 17 additions & 1 deletion source/api-router.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ The class that manages the routes and request parameters
**Parameters**
- $c:string Controllers name
- $file:string Controller's filepath without the php extension
- $name:string Optional. Controller's class name, $c is used by default

Example:
```
Expand All @@ -32,6 +31,23 @@ Router::route('hello/(.*)', function($x){ echo 'Hello '.$x; });
Router::route('edit_page_/(.*)', function($x){ ... }, 'POST', 'editor');
```

### post ()
(static) Registers a new route.

**Parameters**
- $r:string The path
- $fn:function Callback for the route
- $permissions:string (optional) User persmissions that restrict access


### get ()
(static) Registers a new route.

**Parameters**
- $r:string The path
- $fn:function Callback for the route
- $permissions:string (optional) User persmissions that restrict access


### onController ()
(static) Registers a function to run right after the controller class construction.
Expand Down

0 comments on commit 76f25c0

Please sign in to comment.