Skip to content

Commit 4bcc5a1

Browse files
author
Wazabii
committed
Guide
1 parent 60cc121 commit 4bcc5a1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Connect.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public function setCharset(string $charset): void
5454
*/
5555
public static function setPrefix(string $prefix): void
5656
{
57+
if (substr($prefix, -1) !== "_") {
58+
throw new \InvalidArgumentException("The Prefix has to end with a underscore e.g. (prefix\"_\")!", 1);
59+
}
5760
self::$prefix = $prefix;
5861
}
5962

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,29 @@ MaplePHP - MySQL queries is a powerful yet **user-friendly** library for making
33

44
The guide is not complete; more content will be added soon.
55

6-
### Select 1:
6+
7+
## Connect to the database
8+
9+
```php
10+
use MaplePHP\Query\Connect;
11+
12+
$connect = new Connect($server, $user, $password, $databaseName);
13+
$connect->setCharset("utf8mb4");
14+
// Recommened: Set TABLE prefix. This will make your life easier
15+
// MaplePHP DB class will "automatically prepend" it to the table names.
16+
$connect->setPrefix("maple_");
17+
$connect->execute();
18+
19+
```
20+
21+
## Make queries
22+
Start with the namespace
723
```php
824
use MaplePHP\Query\DB;
25+
```
926

27+
### Select 1:
28+
```php
1029
$select = DB::select("id,firstname,lastname", "users a")->whereId(1)->where("status", 0, ">")->limit(1);
1130
$select->join("login b", "b.user_id = a.id");
1231
$obj = $select->get(); // Get one row result as object

0 commit comments

Comments
 (0)