Created
January 8, 2015 10:53
-
-
Save proudcommerce/53a7d4b35f78ca9c4679 to your computer and use it in GitHub Desktop.
this function checks if a given column in a given database table exists. thanks to tim from shoptimax for this snippet.
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
protected function _dbColumnExist($sTable, $sColumn) | |
{ | |
$sDbName = oxRegistry::getConfig()->getConfigParam('dbName'); | |
$sSql = sprintf("SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s' " | |
. " AND COLUMN_NAME = '%s'", | |
$sDbName, $sTable, $sColumn); | |
return oxDb::getDb()->getOne($sSql); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment