本文整理汇总了PHP中tableExists函数的典型用法代码示例。如果您正苦于以下问题:PHP tableExists函数的具体用法?PHP tableExists怎么用?PHP tableExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tableExists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: actionIndex
/**
* Default action register
* Process register form data and take appropriate action
* @param $sid Survey Id to register
* @param $aRegisterErrors array of errors when try to register
* @return
*/
public function actionIndex($sid = null)
{
if (!is_null($sid)) {
$iSurveyId = $sid;
} else {
$iSurveyId = Yii::app()->request->getPost('sid');
}
$oSurvey = Survey::model()->find("sid=:sid", array(':sid' => $iSurveyId));
$sLanguage = Yii::app()->request->getParam('lang');
if (!$sLanguage) {
$sLanguage = Survey::model()->findByPk($iSurveyId)->language;
}
if (!$oSurvey) {
throw new CHttpException(404, "The survey in which you are trying to participate does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
} elseif ($oSurvey->allowregister != 'Y' || !tableExists("{{tokens_{$iSurveyId}}}")) {
throw new CHttpException(404, "The survey in which you are trying to register don't accept registration. It may have been updated or the link you were given is outdated or incorrect.");
} elseif (!is_null($oSurvey->expires) && $oSurvey->expires < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'))) {
$this->redirect(array('survey/index', 'sid' => $iSurveyId, 'lang' => $sLanguage));
}
Yii::app()->setLanguage($sLanguage);
$event = new PluginEvent('beforeRegister');
$event->set('surveyid', $iSurveyId);
$event->set('lang', $sLanguage);
App()->getPluginManager()->dispatchEvent($event);
$this->sMessage = $event->get('sMessage');
$this->aRegisterErrors = $event->get('aRegisterErrors');
$iTokenId = $event->get('iTokenId');
// Test if we come from register form (and submit)
if (Yii::app()->request->getPost('register') && !$iTokenId) {
self::getRegisterErrors($iSurveyId);
if (empty($this->aRegisterErrors)) {
$iTokenId = self::getTokenId($iSurveyId);
}
}
if (empty($this->aRegisterErrors) && $iTokenId && $this->sMessage === null) {
self::sendRegistrationEmail($iSurveyId, $iTokenId);
}
// Display the page
self::display($iSurveyId);
}
开发者ID:BertHankes,项目名称:LimeSurvey,代码行数:47,代码来源:RegisterController.php
示例17: run
//.........这里部分代码省略.........
if (!$moveResult['mandViolation'] && $moveResult['valid'] && empty($moveResult['invalidSQs'])) {
$moveResult['finished'] = true;
}
}
if ($moveResult['finished'] == true) {
$move = 'movesubmit';
} else {
$_SESSION[$LEMsessid]['step'] = $moveResult['seq'] + 1;
// step is index base 1
$stepInfo = LimeExpressionManager::GetStepIndexInfo($moveResult['seq']);
}
if ($move == "movesubmit" && $moveResult['finished'] == false) {
// then there are errors, so don't finalize the survey
$move = "movenext";
// so will re-display the survey
$invalidLastPage = true;
}
}
// We do not keep the participant session anymore when the same browser is used to answer a second time a survey (let's think of a library PC for instance).
// Previously we used to keep the session and redirect the user to the
// submit page.
if ($surveyMode != 'survey' && $_SESSION[$LEMsessid]['step'] == 0) {
$_SESSION[$LEMsessid]['test'] = time();
display_first_page();
Yii::app()->end();
// So we can still see debug messages
}
// TODO FIXME
if ($thissurvey['active'] == "Y") {
Yii::import("application.libraries.Save");
$cSave = new Save();
}
if ($thissurvey['active'] == "Y" && Yii::app()->request->getPost('saveall')) {
$bTokenAnswerPersitance = $thissurvey['tokenanswerspersistence'] == 'Y' && isset($surveyid) && tableExists('tokens_' . $surveyid);
// must do this here to process the POSTed values
$moveResult = LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['step'], false);
// by jumping to current step, saves data so far
if (!isset($_SESSION[$LEMsessid]['scid']) && !$bTokenAnswerPersitance) {
$cSave->showsaveform();
// generates a form and exits, awaiting input
} else {
// Intentional retest of all conditions to be true, to make sure we do have tokens and surveyid
// Now update lastpage to $_SESSION[$LEMsessid]['step'] in SurveyDynamic, otherwise we land on
// the previous page when we return.
$iResponseID = $_SESSION[$LEMsessid]['srid'];
$oResponse = SurveyDynamic::model($surveyid)->findByPk($iResponseID);
$oResponse->lastpage = $_SESSION[$LEMsessid]['step'];
$oResponse->save();
}
}
if ($thissurvey['active'] == "Y" && Yii::app()->request->getParam('savesubmit')) {
// The response from the save form
// CREATE SAVED CONTROL RECORD USING SAVE FORM INFORMATION
$popup = $cSave->savedcontrol();
if (isset($errormsg) && $errormsg != "") {
$cSave->showsaveform();
// reshow the form if there is an error
}
$moveResult = LimeExpressionManager::GetLastMoveResult(true);
$LEMskipReprocessing = true;
// TODO - does this work automatically for token answer persistence? Used to be savedsilent()
}
//Now, we check mandatory questions if necessary
//CHECK IF ALL CONDITIONAL MANDATORY QUESTIONS THAT APPLY HAVE BEEN ANSWERED
global $notanswered;
if (isset($moveResult) && !$moveResult['finished']) {
开发者ID:BertHankes,项目名称:LimeSurvey,代码行数:67,代码来源:SurveyRuntimeHelper.php
示例18: _newtokentable
/**
* Show dialogs and create a new tokens table
*/
function _newtokentable($iSurveyId)
{
$clang = $this->getController()->lang;
$aSurveyInfo = getSurveyInfo($iSurveyId);
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'create')) {
Yii::app()->session['flashmessage'] = $clang->gT("Tokens have not been initialised for this survey.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
$bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
if ($bTokenExists) {
Yii::app()->session['flashmessage'] = $clang->gT("Tokens already exist for this survey.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
// The user have rigth to create token, then don't test right after
Yii::import('application.helpers.admin.token_helper', true);
if (Yii::app()->request->getQuery('createtable') == "Y") {
createTokenTable($iSurveyId);
LimeExpressionManager::SetDirtyFlag();
// LimeExpressionManager needs to know about the new token table
$this->_renderWrappedTemplate('token', array('message' => array('title' => $clang->gT("Token control"), 'message' => $clang->gT("A token table has been created for this survey.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_{$iSurveyId}\")<br /><br />\n" . "<input type='submit' value='" . $clang->gT("Continue") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}") . "', '_top')\" />\n")));
} elseif (returnGlobal('restoretable') == "Y" && Yii::app()->request->getPost('oldtable')) {
//Rebuild attributedescription value for the surveys table
$table = Yii::app()->db->schema->getTable(Yii::app()->request->getPost('oldtable'));
$fields = array_filter(array_keys($table->columns), 'filterForAttributes');
$fieldcontents = $aSurveyInfo['attributedescriptions'];
if (!is_array($fieldcontents)) {
$fieldcontents = array();
}
foreach ($fields as $fieldname) {
$name = $fieldname;
if ($fieldname[10] == 'c') {
//This belongs to a cpdb attribute
$cpdbattid = substr($fieldname, 15);
$data = ParticipantAttributeName::model()->getAttributeName($cpdbattid, Yii::app()->session['adminlang']);
$name = $data['attribute_name'];
}
if (!isset($fieldcontents[$fieldname])) {
$fieldcontents[$fieldname] = array('description' => $name, 'mandatory' => 'N', 'show_register' => 'N');
}
}
Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => serialize($fieldcontents)));
Yii::app()->db->createCommand()->renameTable(Yii::app()->request->getPost('oldtable'), Yii::app()->db->tablePrefix . "tokens_" . intval($iSurveyId));
Yii::app()->db->schema->getTable(Yii::app()->db->tablePrefix . "tokens_" . intval($iSurveyId), true);
// Refresh schema cache just in case the table existed in the past
//Check that the tokens table has the required fields
TokenDynamic::model($iSurveyId)->checkColumns();
//Add any survey_links from the renamed table
SurveyLink::model()->rebuildLinksFromTokenTable($iSurveyId);
$this->_renderWrappedTemplate('token', array('message' => array('title' => $clang->gT("Import old tokens"), 'message' => $clang->gT("A token table has been created for this survey and the old tokens were imported.") . " (\"" . Yii::app()->db->tablePrefix . "tokens_{$iSurveyId}" . "\")<br /><br />\n" . "<input type='submit' value='" . $clang->gT("Continue") . "' onclick=\"window.open('" . $this->getController()->createUrl("admin/tokens/sa/index/surveyid/{$iSurveyId}") . "', '_top')\" />\n")));
LimeExpressionManager::SetDirtyFlag();
// so that knows that token tables have changed
} else {
$this->getController()->loadHelper('database');
$result = Yii::app()->db->createCommand(dbSelectTablesLike("{{old_tokens_" . intval($iSurveyId) . "_%}}"))->queryAll();
$tcount = count($result);
if ($tcount > 0) {
foreach ($result as $rows) {
$oldlist[] = reset($rows);
}
$aData['oldlist'] = $oldlist;
}
$thissurvey = getSurveyInfo($iSurveyId);
$aData['thissurvey'] = $thissurvey;
$aData['surveyid'] = $iSurveyId;
$aData['tcount'] = $tcount;
$aData['databasetype'] = Yii::app()->db->getDriverName();
$this->_renderWrappedTemplate('token', 'tokenwarning', $aData);
}
}
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:72,代码来源:tokens.php
示例19: getQuotaCompletedCount
/**
* Returns the number of answers matching the quota
*
* @param int $iSurveyId - Survey identification number
* @param int $quotaid - quota id for which you want to compute the completed field
* @return mixed - value of matching entries in the result DB or null
*/
function getQuotaCompletedCount($iSurveyId, $quotaid)
{
if (!tableExists("survey_{$iSurveyId}")) {
// Yii::app()->db->schema->getTable('{{survey_' . $iSurveyId . '}}' are not updated even after Yii::app()->db->schema->refresh();
return;
}
$aColumnName = SurveyDynamic::model($iSurveyId)->getTableSchema()->getColumnNames();
$aQuotas = getQuotaInformation($iSurveyId, Survey::model()->findByPk($iSurveyId)->language, $quotaid);
$aQuota = $aQuotas[0];
if (Yii::app()->db->schema->getTable('{{survey_' . $iSurveyId . '}}') && count($aQuota['members']) > 0) {
// Keep a list of fields for easy reference
$aQuotaColumns = array();
foreach ($aQuota['members'] as $member) {
if (in_array($member['fieldname'], $aColumnName)) {
$aQuotaColumns[$member['fieldname']][] = $member['value'];
} else {
return;
}
}
$oCriteria = new CDbCriteria();
$oCriteria->condition = "submitdate IS NOT NULL";
foreach ($aQuotaColumns as $sColumn => $aValue) {
if (count($aValue) == 1) {
$oCriteria->compare(Yii::app()->db->quoteColumnName($sColumn), $aValue);
// NO need params : compare bind
} else {
$oCriteria->addInCondition(Yii::app()->db->quoteColumnName($sColumn), $aValue);
// NO need params : addInCondition bind
}
}
return SurveyDynamic::model($iSurveyId)->count($oCriteria);
}
}
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:40,代码来源:common_helper.php
示例20: getLanguageNameFromCode
else { ?>
<option value='<?php echo $lang; ?>'><?php echo getLanguageNameFromCode($lang,false); ?></option>
<?php }
} ?>
</select>
</td></tr></table></div>
</td>
</tr>
<?php } ?>
<tr>
<td colspan='3' align='center'>
<input type='submit' id='submitdata' value='<?php $clang->eT("Submit"); ?>'
<?php if (tableExists('tokens_'.$thissurvey['sid']))
{ ?>
disabled='disabled'/>
<?php }
else
{ ?>
/>
<?php } ?>
</td>
</tr>
<?php }
elseif ($thissurvey['active'] == "N")
{ ?>
<tr>
<td colspan='3' align='center'>
<font color='red'><strong><?php $clang->eT("This survey is not yet active. Your response cannot be saved"); ?>
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:31,代码来源:active_html_view.php
注:本文中的tableExists函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论