Komendy:

Sposób wyświetlania

SELECT * FROM tabela \gx        - Odpowiednik \G (dla zapytania)

\x                              - włączenie trybu pionowego na stałe

\x auto                         - przełączenie na pionowy widok tylko wtedy, gdy wiersze są za szerokie dla ekranu


SELECT * FROM tabela \x\g\x    - włącza tryb pionowy, wysła zapytanie i wyłącza tryb w jednej linii
 

Operacje na bazach danych

\l               - lista baz danych

\c moja_baza     - połączenie z bazą

Tabele

\d                      - lista relacji
\dt                     - lista tabel


\d  moja_tabela         - struktura tabeli
\d+ moja_tabela         - szczegóły tabeli: komentarze, rozmiar na dysku,

 

Authentication – podstawowe komendy

W szablonie:

<?php
  $user_id = $this->getRequest()->getAttribute('identity')->getIdentifier();
?>

W kontrolerze:

$user_id = $this->Authentication->getIdentity()->getIdentifier();

$role = $this->Authentication->getIdentity()->get('role');

$role == 'admin' || 'user'

Wyłączenie z dostępu po zalogowaniu

use Cake\Event\EventInterface;


public function beforeFilter(EventInterface $event): void
{
        parent::beforeFilter($event);

        if(!$this->is_admin) {
            $this->Flash->error(__('Nie ma takiej strony'));
            $event->setResult($this->redirect('/'));
            return;
        }

        $this->Authentication->addUnauthenticatedActions(['edit', 'changePassword' ]);
    }

Aktualizacja URL

let url = new URL(location.href);

$("#proj-tabs").find(".nav-link").on('click', function() {

    var tab_name = $(this).attr('data-bs-target').replace("#", "");

    url.searchParams.set("s_tab", tab_name);

    history.replaceState(null, null, url.href);

});