Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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