当前位置: 首页>>代码示例>>PHP>>正文


PHP tableExists函数代码示例

本文整理汇总了PHP中tableExists函数的典型用法代码示例。如果您正苦于以下问题:PHP tableExists函数的具体用法?PHP tableExists怎么用?PHP tableExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了tableExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $bDrop = $this->uri->segment(3);
     $aTableNames = modelsToTableNames();
     foreach ($aTableNames as $k => $sTableName) {
         $oSqlBuilder = new SqlBuilder();
         //** Build tables
         $oTableName = new $k();
         $sCreateSql = $oSqlBuilder->setTableName($sTableName)->getCreateTableString($oTableName->db);
         $this->db->query('FLUSH TABLES;');
         if ($bDrop) {
             $this->db->query($oSqlBuilder->getDropTableString());
         }
         if (!tableExists($sTableName)) {
             $this->db->query($sCreateSql);
         }
         //** Add in any default data
         foreach ($oSqlBuilder->getDefaultDataArray($oTableName->data) as $v) {
             //$oTableName->
             $this->db->query($v);
         }
     }
     foreach ($aTableNames as $k => $sTableName) {
         $oTableName = new $k();
         //** Make forms
         if (!empty($oTableName->form)) {
             $oFormBuilder = new FormBuilder();
             $sForm = $oFormBuilder->setTableName($sTableName)->setFormName($sTableName)->setFormData($oTableName->form)->getFormString();
             createFile('views/admin/includes/forms/' . $sTableName . '_form.php', $sForm);
         }
     }
 }
开发者ID:nhc,项目名称:agency-cms,代码行数:32,代码来源:deploy.php

示例2: importHoldingsData

function importHoldingsData($host, $db, $user, $pass, $data)
{
    // Create connection
    $con = mysqli_connect($host, $user, $pass, $db);
    // Check connection
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
        return;
    }
    //create table if it doesn't exist yet
    $tableExists = tableExists($con, "current_holdings");
    if (!$tableExists) {
        $createTable = "CREATE TABLE `pse_data`.`current_holdings` (\n\t\t\t\t\t\t\t  `quote` VARCHAR(16) NOT NULL,\n\t\t\t\t\t\t\t  `datebuy` DATE NOT NULL,\n\t\t\t\t\t\t\t  `pricebuy` FLOAT NULL,\n\t\t\t\t\t\t\t  `volume` INT NULL,\n\t\t\t\t\t\t\t  `pricestoploss` FLOAT NULL,\n\t\t\t\t\t\t\t  PRIMARY KEY (`quote`))\n\t\t\t\t\t\t\tCOMMENT = 'contains the current stocks being held and the stop loss selling price'";
        $result = mysqli_query($con, $createTable);
        echo "importHoldingsData: Created table 'current_holdings' <Br><Br>";
    }
    $sql = "REPLACE INTO current_holdings (datebuy, quote, pricebuy, volume)";
    $holdingValues = " VALUES";
    $dataSize = count($data);
    $ctr = 0;
    foreach ($data as $holdings) {
        $holdingValues = $holdingValues . "('" . $holdings['date'] . "','" . $holdings['company'] . "','" . $holdings['pricebuy'] . "','" . $holdings['volume'] . "')";
        $ctr++;
        if ($ctr < $dataSize) {
            $holdingValues = $holdingValues . ", ";
        }
    }
    $sql = $sql . $holdingValues;
    echo "{$sql}";
    $result = mysqli_query($con, $sql);
    if (mysqli_affected_rows($con) < 1) {
        echo "importHoldingsData: Failed Value Insertion!<Br>";
    }
    mysqli_close($con);
}
开发者ID:panbognot,项目名称:stana,代码行数:35,代码来源:dataAccountManagement.php

示例3: index

 function index()
 {
     $u = new User();
     $u->load();
     if (tableExists('users')) {
         echo 'table exists<br />';
     }
 }
开发者ID:nhc,项目名称:agency-cms,代码行数:8,代码来源:tester.php

示例4: deleteTable

function deleteTable($name)
{
    if (tableExists($name)) {
        queryMysql("DROP TABLE {$name}");
    } else {
        echo "Table '{$name}' doesn't exist<br />";
    }
}
开发者ID:reidcurley,项目名称:oreillyPhpMysqlJavascript,代码行数:8,代码来源:rnfunctions.php

示例5: createTable

function createTable($name, $query)
{
    if (tableExists($name)) {
        echo "Table {$name} already exists";
    } else {
        queryMySql("CREATE TABLE {$name}({$query})");
        echo "Table {$name} Created";
    }
}
开发者ID:ShaklinSyed,项目名称:todo,代码行数:9,代码来源:lib.php

示例6: createTable

function createTable($name, $query)
{
    if (tableExists($name)) {
        echo "Table '{$name}' already exists<br />";
    } else {
        queryMysql("CREATE TABLE {$name}({$query})");
        echo "Table '{$name}' created<br />";
    }
}
开发者ID:klewasps,项目名称:velvet,代码行数:9,代码来源:rnfunctions.php

示例7: count_by_id

function count_by_id($table)
{
    global $db;
    if (tableExists($table)) {
        $sql = "SELECT COUNT(id) AS total FROM " . $db->escape($table);
        $result = $db->query($sql);
        return $db->fetch_assoc($result);
    }
}
开发者ID:antring,项目名称:inventory-ks,代码行数:9,代码来源:sql.php

示例8: __construct

 public function __construct($resp = NULL)
 {
     global $db;
     $this->db = $db;
     $this->response = $resp ? $resp : new response();
     if (!tableExists('scratchcard')) {
         $this->install();
     }
     $this->table = new table('scratchcard');
 }
开发者ID:carriercomm,项目名称:Nuance,代码行数:10,代码来源:scratchcard.php

示例9: createTable

function createTable($name, $query)
{
    if (tableExists($name)) {
        echo "Table '{$name}' already exists ,updating table...!!<br />";
        //  queryMysql("ALTER TABLE $name MODIFY $query");
        //  echo "Congrats Table '$name' successfully Updated !@!";
    } else {
        queryMysql("CREATE TABLE {$name}({$query})");
        echo "Table '{$name}' created<br/>";
    }
}
开发者ID:klewasps,项目名称:velvet,代码行数:11,代码来源:requirefn.php

示例10: sql_start

function sql_start()
{
    $db = new PDO(SQL_DSN, SQL_USER, SQL_PASS);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    //Remove this section to skip checking for table
    if (!tableExists($db, 'youbulletin')) {
        $db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `youbulletin` (\n\t\t\t`id` int(10) unsigned NOT NULL,\n\t\t\t  `type` tinytext NOT NULL,\n\t\t\t  `data` text NOT NULL,\n\t\t\t  `title` text NOT NULL,\n\t\t\t  `duration` int(10) unsigned NOT NULL,\n\t\t\t  `thumbnail` text NOT NULL,\n\t\t\t  `name` tinytext NOT NULL,\n\t\t\t  `comment` text NOT NULL,\n\t\t\t  `ip` tinytext NOT NULL,\n\t\t\t  `posttime` int(10) unsigned NOT NULL,\n\t\t\t  `views` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t  `viewdata` longtext NOT NULL,\n\t\t\t  `comments` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t  `commentdata` longtext NOT NULL,\n\t\t\t  `viewtime` double NOT NULL,\n\t\t\t  `flags` text NOT NULL\n\t\t\t) AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;\n\n\t\t\tALTER TABLE `youbulletin` ADD PRIMARY KEY (`id`);\n\n\t\t\tALTER TABLE `youbulletin` MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;\n\t\t");
    }
    // ^ Remove this section to skip checking for table ^
    return $db;
}
开发者ID:jackson-c,项目名称:YouBulletin,代码行数:11,代码来源:sql.php

示例11: actiontokens

 function actiontokens($surveyid, $token, $langcode = '')
 {
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('sanitize');
     $sLanguageCode = $langcode;
     $iSurveyID = $surveyid;
     $sToken = $token;
     $sToken = sanitize_token($sToken);
     if (!$iSurveyID) {
         $this->redirect($this->getController()->createUrl('/'));
     }
     $iSurveyID = (int) $iSurveyID;
     //Check that there is a SID
     // Get passed language from form, so that we dont loose this!
     if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
         $baselang = Survey::model()->findByPk($iSurveyID)->language;
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($baselang);
     } else {
         $sLanguageCode = sanitize_languagecode($sLanguageCode);
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($sLanguageCode);
         $baselang = $sLanguageCode;
     }
     Yii::app()->lang = $clang;
     $thissurvey = getSurveyInfo($iSurveyID, $baselang);
     if ($thissurvey == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
         $html = $clang->gT('This survey does not seem to exist.');
     } else {
         $row = Tokens_dynamic::model($iSurveyID)->getEmailStatus($sToken);
         if ($row == false) {
             $html = $clang->gT('You are not a participant in this survey.');
         } else {
             $usresult = $row['emailstatus'];
             if ($usresult == 'OptOut') {
                 $usresult = Tokens_dynamic::model($iSurveyID)->updateEmailStatus($sToken, 'OK');
                 $html = $clang->gT('You have been successfully added back to this survey.');
             } else {
                 if ($usresult == 'OK') {
                     $html = $clang->gT('You are already a part of this survey.');
                 } else {
                     $html = $clang->gT('You have been already removed from this survey.');
                 }
             }
         }
     }
     //PRINT COMPLETED PAGE
     if (!$thissurvey['templatedir']) {
         $thistpl = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
     } else {
         $thistpl = getTemplatePath($thissurvey['templatedir']);
     }
     $this->_renderHtml($html, $thistpl, $clang);
 }
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:54,代码来源:OptinController.php

示例12: actiontokens

 function actiontokens($surveyid, $token, $langcode = '')
 {
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('sanitize');
     $sLanguageCode = $langcode;
     $iSurveyID = $surveyid;
     $sToken = $token;
     $sToken = sanitize_token($sToken);
     if (!$iSurveyID) {
         $this->redirect(array('/'));
     }
     $iSurveyID = (int) $iSurveyID;
     //Check that there is a SID
     // Get passed language from form, so that we dont loose this!
     if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
         $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($sBaseLanguage);
     } else {
         $sLanguageCode = sanitize_languagecode($sLanguageCode);
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($sLanguageCode);
         $sBaseLanguage = $sLanguageCode;
     }
     Yii::app()->lang = $clang;
     $aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
     if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
         $sMessage = $clang->gT('This survey does not seem to exist.');
     } else {
         $oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token));
         if (!isset($oToken)) {
             $sMessage = $clang->gT('You are not a participant in this survey.');
         } else {
             if ($oToken->emailstatus == 'OptOut') {
                 $oToken->emailstatus = 'OK';
                 $oToken->save();
                 $sMessage = $clang->gT('You have been successfully added back to this survey.');
             } elseif ($oToken->emailstatus == 'OK') {
                 $sMessage = $clang->gT('You are already a part of this survey.');
             } else {
                 $sMessage = $clang->gT('You have been already removed from this survey.');
             }
         }
     }
     //PRINT COMPLETED PAGE
     if (!$aSurveyInfo['templatedir']) {
         $sTemplate = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
     } else {
         $sTemplate = getTemplatePath($aSurveyInfo['templatedir']);
     }
     $this->_renderHtml($sMessage, $sTemplate, $clang, $aSurveyInfo);
 }
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:52,代码来源:OptinController.php

示例13: sql_start

function sql_start()
{
    $db = new PDO(SQL_DSN, SQL_USER, SQL_PASS);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    //Remove this section to skip checking for tables
    if (!tableExists($db, 'users')) {
        $db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `users` (\n\t\t\t  `id64` bigint(20) unsigned NOT NULL,\n\t\t\t  `points` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t  `items` text NOT NULL,\n\t\t\t  `donation_total` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t  `donation_credited` int(10) unsigned NOT NULL DEFAULT '0',\n\t\t\t  `last_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n\t\t\t);\n\n\t\t\tALTER TABLE `users` ADD PRIMARY KEY (`id64`);\n\t\t\t");
    }
    if (!tableExists($db, 'charges')) {
        $db->query("\n\t\t\tCREATE TABLE IF NOT EXISTS `charges` (\n\t\t\t  `id64` bigint(20) unsigned NOT NULL,\n\t\t\t  `email` text NOT NULL,\n\t\t\t  `time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t\t  `amount` int(10) unsigned NOT NULL,\n\t\t\t  `points_before` int(10) unsigned NOT NULL,\n\t\t\t  `points_after` int(10) unsigned NOT NULL\n\t\t\t);\n\t\t\t");
    }
    // ^ Remove this section to skip checking for tables ^
    return $db;
}
开发者ID:jackson-c,项目名称:PointShop-Donation,代码行数:14,代码来源:sql.php

示例14: actiontokens

 function actiontokens($surveyid, $token, $langcode = '')
 {
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('sanitize');
     $sLanguageCode = $langcode;
     $iSurveyID = $surveyid;
     $sToken = $token;
     $sToken = sanitize_token($sToken);
     if (!$iSurveyID) {
         $this->redirect(array('/'));
     }
     $iSurveyID = (int) $iSurveyID;
     //Check that there is a SID
     // Get passed language from form, so that we dont loose this!
     if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
         $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
     } else {
         $sBaseLanguage = sanitize_languagecode($sLanguageCode);
     }
     Yii::app()->setLanguage($sBaseLanguage);
     $aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
     if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
         throw new CHttpException(404, "This survey does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
     } else {
         LimeExpressionManager::singleton()->loadTokenInformation($iSurveyID, $token, false);
         $oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token));
         if (!isset($oToken)) {
             $sMessage = gT('You are not a participant in this survey.');
         } else {
             if ($oToken->emailstatus == 'OptOut') {
                 $oToken->emailstatus = 'OK';
                 $oToken->save();
                 $sMessage = gT('You have been successfully added back to this survey.');
             } elseif ($oToken->emailstatus == 'OK') {
                 $sMessage = gT('You are already a part of this survey.');
             } else {
                 $sMessage = gT('You have been already removed from this survey.');
             }
         }
     }
     //PRINT COMPLETED PAGE
     if (!$aSurveyInfo['templatedir']) {
         $sTemplate = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
     } else {
         $sTemplate = getTemplatePath($aSurveyInfo['templatedir']);
     }
     $this->_renderHtml($sMessage, $sTemplate, $aSurveyInfo);
 }
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:48,代码来源:OptinController.php

示例15: is_projectsend_installed

/**
 * Check if ProjectSend is installed by looping over the main tables.
 * All tables must exist to verify the installation.
 * If any table is missing, the installation is considered corrupt.
 */
function is_projectsend_installed()
{
    global $current_tables;
    $tables_missing = 0;
    /**
     * This table list is defined on sys.vars.php
     */
    foreach ($current_tables as $table) {
        if (!tableExists($table)) {
            $tables_missing++;
        }
    }
    if ($tables_missing > 0) {
        return false;
    } else {
        return true;
    }
}
开发者ID:baldzern4,项目名称:ProjectSend,代码行数:23,代码来源:functions.php


注:本文中的tableExists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。