-
Notifications
You must be signed in to change notification settings - Fork 0
/
todo.php
117 lines (92 loc) · 3.75 KB
/
todo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/*
|--------------------------------------------------------------------------
| Aptitude TODO List
|--------------------------------------------------------------------------
|
| Things that needs to be taken care of and changed in the system.
| Everything from small to large changes.
|
| NOTE! Most of the code in this file can not be run on it's own, it will
| fail if you try to do so.
|
*/
/*
|--------------------------------------------------------------------------
| Application loading/booting
|--------------------------------------------------------------------------
|
| The whole application should be loaded, booted, send a response and
| run a shutdown from the Application class.
|
*/
// Boots up the application, loads (insert?) app config file, add resolvers
// to the IoC container, register aliases.
$app->boot();
// Checks the routes and returns a response if one was supplied. If no
// response is set it should throw an Exception. (Not sure if it should?)
$app->run();
// Probably not needed for quie a while. Would require more advanced
// features to be added.
// The shutdown would mainly be a bunch of supplied closures doing their
// thing after the application has sent the response.
$app->shutdown();
/*
|--------------------------------------------------------------------------
| Database class
|--------------------------------------------------------------------------
|
| A class that should be able to connect to the most common SQL databases
| with help from the PHP PDO class.
|
| First priority is MySQL suport and after that PostgreSQL and then SQLite
| support.
|
*/
// Instantiate a new DB class assigned to the $db variable.
$db = new DB;
// Simple example of what a select getting all users should look like.
$users = $db->table('users')->get();
// A more advanced select getting only a few collumns.
$users = $db->select(array('username', 'email'))->table('users')->get();
// You should also be able to do a select without supplying an array as
// the value and instead only supply regular params.
$users = $db->select('username', 'email')->table('users')->get();
// Where statements can be done in one of two ways, either without the
// operator in which case it will use the equals to operator or it can
// be used by supplying the operator to use in the where statement.
// Where equals to.
$users = $db->table('users')->where('id', 1)->get();
// Where value in array.
$users = $db->table('users')->where('id', 'IN', array(1, 2, 3))->get();
// Where value is less than.
$users = $db->table('users')->where('id', '<', 10)->get();
// Where value like.
$users = $db->table('users')->where('username', 'LIKE', 'John')->get();
// Get the first record found with the current statement.
$user = $db->table('users')->where('authenticated', 1)->first();
// Get the last record found with the current statement.
$user = $db->table('users')->where('authenticated', 1)->last();
// Joins with a callback function for the join settings.
// Not really sure if this will work?! Would be awesome tough!
$users = $db->table('users')->join(function($join) {
$join->table('settings')->where('users.id', 'settings.user_id');
})->get();
// Join from table settings ON users.id = settings.user_id.
$users = $db->table('users')->join('settings', 'users.id', '=', 'settings.user_id');
/*
|--------------------------------------------------------------------------
| MongoDB Class
|--------------------------------------------------------------------------
|
| MongoDB support. Not something to to in the near future.
|
*/
/*
|--------------------------------------------------------------------------
| DI (Dependency Injection)
|--------------------------------------------------------------------------
|
| Might be a good feature? Needs more research before implementing.
|
*/