You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41-4Lines changed: 41 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,14 +36,15 @@ $db = mweb::connect('localhost', 'root', '', 'students_db'); // You are connecte
36
36
```
37
37
select_all($table_name, null, null)
38
38
```
39
-
This will accept 1 parameter the which is the table that will be selected
39
+
This will accept 1 parameter which is the table that will be selected
40
40
#### Example:
41
41
```
42
-
$db->select_all('tbl_users');
42
+
$db->select_all('tbl_users'); // Get all the users
43
+
43
44
$users = $db->get();
44
45
````
45
46
This will return an associative array. You can access this object by using the lambda expression (->).
46
-
Example:
47
+
#### Example:
47
48
```
48
49
<tableborder="1">
49
50
<thead>
@@ -76,4 +77,40 @@ Example:
76
77
77
78
Note: When you are performing SQL select statement also remember that you call this method $db->get() or $db->get_single_row() (for selecting single row only)
78
79
for every query to get the return values in your queries
79
-
if not you query is not take effect
80
+
if not you query is not take effect
81
+
82
+
If you want to return a single row only kindly call the method
83
+
```
84
+
$users = $db->get_single_row(); // This will return a single row only
85
+
echo $users->fname; // Display the first name
86
+
```
87
+
Note: If you perform a get_single_row() method and theres no data in your table the return value of this method is 0 indicating theres no data will be return
88
+
89
+
### Selecting for specific fields or column in the table by using the method
90
+
```
91
+
select_fields($table_name, $arr_fields)
92
+
```
93
+
The first parameter is the table that will be selected in the database<br />
94
+
The second parameter accepts an associative array which consists of array of fields<br />
95
+
#### Example:
96
+
```
97
+
$arr_fields = array('fname', 'lname', 'mname'); // Create an array of fields that will be selected in the table
98
+
99
+
$db->select_fields('tbl_users', $array_fields); // Call the method
100
+
101
+
$users = $db->get(); // This will return an associative array
102
+
```
103
+
104
+
### SQL limit by using the method
105
+
```
106
+
// This will accepts a integer value that the number of rows that you want to limit in your select statement
107
+
limit($num);
108
+
```
109
+
#### Example:
110
+
```
111
+
$db->select_all('tbl_users');
112
+
113
+
$db->limit(10); // Limit the number of return rows to 10
114
+
115
+
$users = $db->get(); // This will return an associative array
0 commit comments