Skip to content

Instantly share code, notes, and snippets.

View Mihail-Obrazenko's full-sized avatar

Mikhail Obrazenko Mihail-Obrazenko

View GitHub Profile
@Mihail-Obrazenko
Mihail-Obrazenko / transaction.php
Created August 9, 2018 07:19 — forked from KaduNovoK/transaction.php
Transactions in Symfony 2 and Doctrine 2
<?php
// Code sample to use Transactions
// Get the Entity Manager
$em = $this->getDoctrine()->getEntityManager();
// Suspend the auto-commit
$em->getConnection()->beginTransaction();
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@Mihail-Obrazenko
Mihail-Obrazenko / Doctrine.php
Created May 11, 2018 14:04 — forked from jakzal/Doctrine.php
Use Doctrine and Symfony Kernel in phpunit tests
<?php
declare(strict_types=1);
namespace SymfonyLive\Mastermind\Adapters\Database;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\Tools\SchemaTool;
use RuntimeException;
<?php
use Symfony\Bundle\SecurityBundle\Command\InitAclCommand;
use Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand;
use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand;
require_once __DIR__.'/bootstrap.php.cache';
require_once __DIR__.'/AppKernel.php';
@Mihail-Obrazenko
Mihail-Obrazenko / postgres-cheats-list.txt
Last active December 4, 2017 22:04
Postgres cheatsheet
Backup / Export:
pg_dump -h localhost -p 5434 -U postgres_user -F c -b -v -f "/path/db.bak" db_name
Restore / Import:
pg_restore -h localhost -p 5434 -U postgres_user -d db_name -v "/path/db.bak"
-- Version:
select version()
-- ТОП20 наибольших таблиц
@Mihail-Obrazenko
Mihail-Obrazenko / bootstrap
Created July 16, 2016 16:07 — forked from zinovyev/bootstrap
Vagrant nginx & php-fpm bootstrap.sh
#!/usr/bin/env bash
#
# Vagrant nginx & php-fpm
# Vagrant basic bootstrap.sh file configuration for getting a ready to use dev solution
#
# Ivan Zinovyev <vanyazin@gmail.com>
#
# (The "ubuntu/trusty64" box was used and tested)
#