Skip to content

Instantly share code, notes, and snippets.

@cbrhex
cbrhex / helpers.php
Created February 24, 2017 07:57 — forked from Ellrion/helpers.php
Showing all database queries in Laravel 5.2+
<?php
if (! function_exists('dbd')) {
/**
* Showing all database queries.
* Отображение всех запросов в базу.
*
* @param null|\Illuminate\Console\Command|\Psr\Log\LoggerInterface $channel
*/
function dbd($channel = null)
// REGIONS
Schema::create('regions', function (Blueprint $table) {
$table->increments('id');
$table->tinyInteger('code')->unique();
$table->string('title', 25)->unique();
$table->string('image');
$table->string('description', 100);
$table->timestamps();
});
CREATE DEFINER=`root`@`root` PROCEDURE `procedure_name`()
BEGIN
IF (SELECT count(*)
FROM information_schema.TABLES
WHERE
TABLE_SCHEMA = 'DB_NAME' -- Database name
AND TABLE_NAME = 'TABLE_NAME' AND ...) = 0 THEN
SELECT ...; -- not exists
ELSE