Skip to content

Commit e5cb630

Browse files
committed
update readme
1 parent b4ab164 commit e5cb630

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ $db = mweb::connect('localhost', 'root', '', 'students_db'); // You are connecte
3636
```
3737
select_all($table_name, null, null)
3838
```
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
4040
#### Example:
4141
```
42-
$db->select_all('tbl_users');
42+
$db->select_all('tbl_users'); // Get all the users
43+
4344
$users = $db->get();
4445
````
4546
This will return an associative array. You can access this object by using the lambda expression (->).
46-
Example:
47+
#### Example:
4748
```
4849
<table border="1">
4950
<thead>
@@ -76,4 +77,40 @@ Example:
7677
7778
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)
7879
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
116+
```

0 commit comments

Comments
 (0)