ALTER TABLE `si_invoices` ADD `domain_id` INT NOT NULL AFTER `id` ;function checkTableExists in include/sql_queries.php
function checkTableExists($table = "" ) {
$table == "" ? TB_PREFIX."biller" : $table;
global $LANG;
global $dbh;
global $config;
switch ($config->database->adapter)
{
case "pdo_pgsql":
$sql = 'SELECT 1 FROM pg_tables WHERE tablename = '.$table.' LIMIT 1';
break;
case "pdo_sqlite":
$sql = 'SELECT * FROM '.$table.'LIMIT 1';
break;
case "pdo_mysql":
default:
//mysql
//$sql = "SELECT 1 FROM INFORMATION_SCHEMA.TABLES where table_name = :table LIMIT 1";
$sql = "SHOW TABLES LIKE '".$table."'";
break;
}
//$sth = $dbh->prepare($sql);
$sth = dbQuery($sql);
if ($sth->fetchAll())
{
return true;
} else {
return false;
}
}
function checkTableExists($table) {
global $LANG;
global $dbh;
global $config;
switch ($config->database->adapter)
{
case "pdo_pgsql":
$sql = 'SELECT 1 FROM pg_tables WHERE tablename = :table LIMIT 1';
break;
case "pdo_sqlite":
$sql = 'SELECT * FROM :table LIMIT 1';
break;
case "pdo_mysql":
default:
//mysql
$sql = "SELECT 1 FROM INFORMATION_SCHEMA.TABLES where table_name = :table LIMIT 1";
break;
}
$sth = $dbh->prepare($sql);
{
/* if ($sth && $sth->execute(array(':table' => $table))) {
if ($sth->fetch()) {
return true;
} else {
return false;
}
} else { */
return true;
}
}
function checkFieldExists($table,$field) {
global $LANG;
global $dbh;
global $db_server;
$sql = "SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE column_name = :field AND table_name = :table LIMIT 1";
if ($db_server == 'pgsql') {
// Use a nicer syntax
$sql = "SELECT 1 FROM pg_attribute a INNER JOIN pg_class c ON (a.attrelid = c.oid) WHERE c.relkind = 'r' AND c.relname = :table AND a.attname = :field AND NOT a.attisdropped AND a.attnum > 0 LIMIT 1";
}
$sth = $dbh->prepare($sql);
{
/* if ($sth && $sth->execute(array(':field' => $field, ':table' => $table))) {
if ($sth->fetch()) {
return true;
} else {
return false;
}
} else { */
return true;
}
}
1 to 27 of 27