Skip to content

Commit 4f76697

Browse files
committed
Merge branch 'master' of https://github.com/webdevlabs/phreak
2 parents a789ff3 + 1015aea commit 4f76697

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
[![Build Status](https://travis-ci.org/webdevlabs/phreak.svg?branch=master)](https://travis-ci.org/webdevlabs/phreak)
33
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/45799a2694d74bc784c62a89d24c9b5a)](https://www.codacy.com/app/webdevlabs/phreak?utm_source=github.com&utm_medium=referral&utm_content=webdevlabs/phreak&utm_campaign=Badge_Grade)
44
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/bd0c18b6-3e25-4c13-8969-7d28bc41eaf3/mini.png)](https://insight.sensiolabs.com/projects/bd0c18b6-3e25-4c13-8969-7d28bc41eaf3)
5-
[![Dependency Status](https://www.versioneye.com/user/projects/58f730d9710da2004fad45d7/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/58f730d9710da2004fad45d7)
65
[![StyleCI](https://styleci.io/repos/86944823/shield?branch=master)](https://styleci.io/repos/86944823)
76

87
### ultra-light fast php framework powered by:
@@ -126,3 +125,54 @@ class ... {
126125
}
127126
}
128127
```
128+
129+
### Database
130+
You now have different options for managing your database. There are 2 existing database drivers.
131+
Sample database wrapper class DB:: and the well known database mapper Eloquent.
132+
133+
**You control what database driver to load directly from config/database.php**
134+
135+
Example PDO driver fetch queries:
136+
```
137+
* Result: single column
138+
* $count = DB::column('SELECT COUNT(*) FROM `user`);
139+
140+
* Result: an array(key => value) results (i.e. for making a selectbox)
141+
* $pairs = DB::pairs('SELECT `id`, `username` FROM `user`);
142+
143+
* Result: a single row result
144+
* $user = DB::row('SELECT * FROM `user` WHERE `id` = ?', array($user_id));
145+
146+
* Result: a single row result
147+
* $user = DB::row('SELECT * FROM `user` WHERE `id` = :varname', array(":varname"=>"some variable"));
148+
149+
* Result: an array of results
150+
* $banned_users = DB::fetch('SELECT * FROM `user` WHERE `banned` = ?', array(TRUE));
151+
152+
* Result: any query
153+
* $dosql = DB::query('UPDATE `settigs` WHERE `setid`=?', ['somesetid']);
154+
155+
* Result: insert user
156+
* DB::insert('users', ['username'=>'test','password'=>'testpass']);
157+
158+
* Result: update user password where user_id = 1
159+
* DB::update('users', ['password'=>'testpass'], '1', 'user_id');
160+
```
161+
162+
The new available method for managing your database is Eloquent (from the Laravel framework).
163+
164+
The *Eloquent ORM* provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table.
165+
166+
*Examples of phreak eloquent usage can be found at the '**modules/elog**' made for demonstration.*
167+
168+
Full documentation can be found at [Eloquent's](https://laravel.com/docs/5.7/eloquent) page.
169+
170+
171+
### Console Commands
172+
You can also execute phreak controllers from your console/crontab by calling the console.php file where the parameters are the filename of the controller.
173+
174+
**Calls the App\Commands\SomeController.php with the proper request method.**
175+
```
176+
php console.php SomeController
177+
```
178+
All console controllers are located in the "app/commands" folder. The folder location is defined in the 'app/ConsoleController.php' and can be changed.

config/modules.php.sample

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
return [
33
'admin',
4-
'test'
4+
'test',
5+
'eloq'
56
];

0 commit comments

Comments
 (0)