Skip to content

Instantly share code, notes, and snippets.

@bantya
Created May 24, 2018 18:56
Show Gist options
  • Save bantya/a08a1d446d5e12097e89ed6e6b63c508 to your computer and use it in GitHub Desktop.
Save bantya/a08a1d446d5e12097e89ed6e6b63c508 to your computer and use it in GitHub Desktop.
PHP: Get all the columns except the defined ones from a table using MySQL
<?php
$create = $pdo->query('show create table users')->fetch(\PDO::FETCH_ASSOC);
$create = $create['Create Table'];
preg_match_all('/^\s+`([^`]+)/m', $create, $matches);
$matches = $matches[1];
$matches = array_diff($matches, $except);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment