Laravel Course

Laravel's database query builder provides a convenient, fluent interface to creating and running database queries.
- It uses PDO parameter binding to protect your application against SQL injection. There is no need to clean strings passed as bindings.


To perform a basic "inner join", you may use the join() method on a query builder instance.
The first argument is the name of the table you need to join to; the remaining arguments specify the relation of the columns for the join.
- You can join to multiple tables in a single query:
$users = DB::table('users')
 ->join('contacts', '', '=', 'contacts.user_id')
 ->join('orders', '', '=', 'orders.user_id')
 ->select('users.*', '', 'orders.price')
- To perform a "left join" query, use the leftJoin() method, in the same way as the join() method.
$users = DB::table('users')
 ->leftJoin('posts', '', '=', 'posts.user_id')


To "union" two queries together, create an initial query and use the union() method to union it with a second query.
$first = DB::table('users')->whereNull('first_name');

$users = DB::table('users')->whereNull('last_name')

- Documentation: Laravel - Database: Query Builder

Daily Test with Code Example

Which tag is used in <table> to create table header cell?
<thead> <th> <td>
  <th>Title 1</th>
  <th>Title 2</th>
Which CSS property sets the distance between lines?
line-height word-spacing margin
.some_class {
  line-height: 150%;
Which function opens a new browser window.
alert() confirm() open()
document.getElementById("id_button").onclick = function(){"");
Indicate the PHP function that returns an array with names of the files and folders inside a directory.
mkdir() scandir() readdir()
$ar_dir = scandir("dir_name");
MySQL Database, Query Builder: Join and Union

Last accessed pages

  1. Add and Remove HTML elements and Content with jQuery (27925)
  2. SHA512 Encrypt hash in JavaScript (17043)
  3. PHP MySQL - WHERE and LIKE (23891)
  4. SHA256 Encrypt hash in JavaScript (13889)
  5. Define Custom List-item Markers, Bullets for UL, OL Lists (4753)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (666)
  2. Read Excel file data in PHP - PhpExcelReader (338)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (316)
  4. querySelector and querySelectorAll (306)
  5. Create simple Website with PHP (270)