Created
May 24, 2018 18:56
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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