Skip to content

Instantly share code, notes, and snippets.

@proudcommerce
Created January 8, 2015 10:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save proudcommerce/53a7d4b35f78ca9c4679 to your computer and use it in GitHub Desktop.
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.
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