Skip to content

Instantly share code, notes, and snippets.

View eubrunocoelho's full-sized avatar

Bruno Coelho eubrunocoelho

View GitHub Profile
@eubrunocoelho
eubrunocoelho / paginate.php
Created June 6, 2024 18:40 — forked from vluzrmos/paginate.php
Laravel Paginate Collection or Array
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@eubrunocoelho
eubrunocoelho / pivot-tables.md
Created August 13, 2023 19:24 — forked from Braunson/pivot-tables.md
Laravel 8.x - Diving into Pivot Tables

Laravel 6 - Diving Into Pivot Tables

Pivot tables can be confusing and a little hard to wrap your head around at first. In this quick article we are going to dive into what a pivot table is, how to create one and finally how to use the pivot table. Let's dive in!

What is a pivot table?

A pivot table is used to connect relationships between two tables. Laravel provides a Many To Many relationship where you can use a pivot table.

@eubrunocoelho
eubrunocoelho / mariadb_operation_example.c
Created April 10, 2022 20:39 — forked from henryscala/mariadb_operation_example.c
mariadb or mysql prepared statements example using C API
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <mysql/mysql.h>
/*
The program is a demonstration of using prepared statements to perform operations on the below table in mariadb.
The statements include: insert, select, delete, etc.
CREATE TABLE person (
@eubrunocoelho
eubrunocoelho / Database.class.php
Created September 21, 2021 18:41 — forked from felladrin/Database.class.php
Classe de conexão ao banco de dados usando PDO no padrão Singleton.
<?php
/**
* Classe de conexão ao banco de dados usando PDO no padrão Singleton.
*
* Exemplo de uso:
* ```
* require_once './Database.class.php';
* $db = Database::conexao(); // Pega a instância da conexao com o banco de dados.
* $insercao = $db->prepare("INSERT INTO pessoa (nome, idade) VALUES (:nome, :idade)"); // Prepara a instrução de inserção de uma pessoa no banco de dados.
* $insercao->bindParam(':nome', $nome); // Faz a ligação entre o parâmetro ":name" da instrução preparada acima com a variável $nome (supondo que $nome contém uma sequência de caracteres fornecida pelo usuário).