Fix case of stdClass
This commit is contained in:
parent
6307b4dac7
commit
c4e155eebb
|
@ -110,7 +110,7 @@ To run a basic query, you may use the `select` method on the `DB` facade:
|
||||||
|
|
||||||
The first argument passed to the `select` method is the raw SQL query, while the second argument is any parameter bindings that need to be bound to the query. Typically, these are the values of the `where` clause constraints. Parameter binding provides protection against SQL injection.
|
The first argument passed to the `select` method is the raw SQL query, while the second argument is any parameter bindings that need to be bound to the query. Typically, these are the values of the `where` clause constraints. Parameter binding provides protection against SQL injection.
|
||||||
|
|
||||||
The `select` method will always return an `array` of results. Each result within the array will be a PHP `StdClass` object, allowing you to access the values of the results:
|
The `select` method will always return an `array` of results. Each result within the array will be a PHP `stdClass` object, allowing you to access the values of the results:
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
echo $user->name;
|
echo $user->name;
|
||||||
|
|
|
@ -57,7 +57,7 @@ You may use the `table` method on the `DB` facade to begin a query. The `table`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
The `get` method returns an `Illuminate\Support\Collection` containing the results where each result is an instance of the PHP `StdClass` object. You may access each column's value by accessing the column as a property of the object:
|
The `get` method returns an `Illuminate\Support\Collection` containing the results where each result is an instance of the PHP `stdClass` object. You may access each column's value by accessing the column as a property of the object:
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
echo $user->name;
|
echo $user->name;
|
||||||
|
@ -65,7 +65,7 @@ The `get` method returns an `Illuminate\Support\Collection` containing the resul
|
||||||
|
|
||||||
#### Retrieving A Single Row / Column From A Table
|
#### Retrieving A Single Row / Column From A Table
|
||||||
|
|
||||||
If you just need to retrieve a single row from the database table, you may use the `first` method. This method will return a single `StdClass` object:
|
If you just need to retrieve a single row from the database table, you may use the `first` method. This method will return a single `stdClass` object:
|
||||||
|
|
||||||
$user = DB::table('users')->where('name', 'John')->first();
|
$user = DB::table('users')->where('name', 'John')->first();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue