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


PHP Dataface_Table::tableExists方法代码示例

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


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

示例1: handle

 function handle(&$params)
 {
     $app =& Dataface_Application::getInstance();
     $record =& $app->getRecord();
     $context = array();
     if (!$record) {
         return PEAR::raiseError("No record is currently selected", DATAFACE_E_ERROR);
     }
     $history_tablename = $record->_table->tablename . '__history';
     if (!Dataface_Table::tableExists($history_tablename)) {
         $context['error'] = PEAR::raiseError("This record has no history yet recorded.", DATAFACE_E_NOTICE);
     } else {
         import('Dataface/HistoryTool.php');
         $history_tool = new Dataface_HistoryTool();
         $history_log = $history_tool->getHistoryLog($record);
         $context['log'] =& $history_log;
         // let's make a query string for the current record
         //current_record_qstr
         $keys = array_keys($record->_table->keys());
         $qstr = array();
         foreach ($keys as $key) {
             $qstr[] = urlencode('--__keys__[' . $key . ']') . '=' . urlencode($record->strval($key));
         }
         $context['current_record_qstr'] = implode('&', $qstr);
     }
     df_display($context, 'Dataface_RecordHistory.html');
 }
开发者ID:promoso,项目名称:HVAC,代码行数:27,代码来源:history.php

示例2: handle

    function handle(&$params)
    {
        $app =& Dataface_Application::getInstance();
        $tt = new Dataface_TranslationTool();
        if (!Dataface_Table::tableExists('dataface__translation_submissions', false)) {
            $tt->createTranslationSubmissionsTable();
            header('Location: ' . $app->url(''));
            exit;
        }
        if (!@$_POST['--submit']) {
            df_display(array('query' => $app->getQuery(), 'success' => @$_REQUEST['--success']), 'Dataface_submit_translation.html');
            exit;
        } else {
            if (@$_POST['subject']) {
                // This is a dummy field - possible hacking attempt
                header('Location: ' . $app->url('-action=list'));
                exit;
            }
            if (@$_POST['--recordid']) {
                $record = df_get_record_by_id($_POST['--recordid']);
                $values = array('record_id' => @$_POST['--recordid'], 'language' => @$_POST['--language'], 'url' => @$_POST['--url'], 'original_text' => @$_POST['--original_text'], 'translated_text' => @$_POST['--translated_text'], 'translated_by' => @$_POST['--translated_by']);
                $trec = new Dataface_Record('dataface__translation_submissions', array());
                $trec->setValues($values);
                $trec->save();
                $email = <<<END
 The following translation was submitted to the web site {$app->url('')}:
 
 Translation for record {$record->getTitle()} which can be viewed at {$record->getURL('-action=view')}.
 This translation was submitted by {$_POST['--translated_by']} after viewing the content at {$_POST['--url']}.
 
 The original text that was being translated is as follows:
 
 {$_POST['--original_text']}
 
 The translation proposed by this person is as follows:
 
 {$_POST['--translated_text']}
 
 For more details about this translation, please visit {$trec->getURL('-action=view')}.
END;
                if (@$app->_conf['admin_email']) {
                    mail($app->_conf['admin_email'], 'New translation submitted', $email);
                }
                if (@$_POST['--redirect'] || @$_POST['--url']) {
                    $url = @$_POST['--redirect'] ? $_POST['--redirect'] : $_POST['--url'];
                    header('Location: ' . $url . '&--msg=' . urlencode('Thank you for your submission.'));
                    exit;
                } else {
                    header('Location: ' . $app->url('') . '&--success=1&--msg=' . urlencode('Thank you for your submission.'));
                    exit;
                }
            } else {
                trigger_error("No record id was provided", E_USER_ERROR);
            }
        }
    }
开发者ID:promoso,项目名称:HVAC,代码行数:56,代码来源:submit_translation.php

示例3: Dataface_ConfigTool_createConfigTable

/**
 * A method to create the configuration table in the database.  The configuration
 * table is where configuration (e.g. fields.ini etc..) may be stored.  This is
 * a new feature in 0.6.14.
 *
 * @author Steve Hannah <shannah@sfu.ca>
 * @created Feb. 26, 2007
 */
function Dataface_ConfigTool_createConfigTable()
{
    $self =& Dataface_ConfigTool::getInstance();
    if (!Dataface_Table::tableExists($self->configTableName, false)) {
        $sql = "CREATE TABLE `" . $self->configTableName . "` (\n\t\t\t\t\tconfig_id int(11) NOT NULL auto_increment primary key,\n\t\t\t\t\t`file` varchar(255) NOT NULL,\n\t\t\t\t\t`section` varchar(128),\n\t\t\t\t\t`key` varchar(128) NOT NULL,\n\t\t\t\t\t`value` text NOT NULL,\n\t\t\t\t\t`lang` varchar(2),\n\t\t\t\t\t`username` varchar(32),\n\t\t\t\t\t`priority` int(5) default 5\n\t\t\t\t\t)";
        $res = xf_db_query($sql, df_db());
        if (!$res) {
            throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
        }
    }
}
开发者ID:minger11,项目名称:Pipeline,代码行数:19,代码来源:createConfigTable.function.php

示例4: refreshMetadataTable

 /**
  * Refreshes the metadata table for a given table.  This means that missing
  * columns and keys are created so that the schema matches the schema of
  * the current table structure.
  *
  * @param string $tablename The name of the table for which the metadata is being
  *					 stored.
  */
 function refreshMetadataTable($tablename = null)
 {
     if (!isset($tablename)) {
         $tablename = $this->tablename;
     }
     if (Dataface_MetadataTool::isMetadataTable($tablename)) {
         return false;
     }
     $app =& Dataface_Application::getInstance();
     $table =& Dataface_Table::loadTable($tablename);
     $md_tablename = $tablename . '__metadata';
     if (!Dataface_Table::tableExists($md_tablename, false)) {
         if ($this->createMetadataTable($tablename)) {
             return true;
         }
     }
     $cols =& $this->getColumns($tablename, false);
     // First we have to go through all of the key fields of the subject table
     // and make sure that they appear in the metadata table.
     $updatePrimaryKey = false;
     foreach ($table->keys() as $field) {
         if (!isset($cols[$field['Field']])) {
             $updatePrimaryKey = true;
             $default = @$field['Default'] ? " DEFAULT {$field['Default']}" : '';
             $sql = "alter table `{$md_tablename}` add column `{$field['Field']}` {$field['Type']}{$default}";
             $res = xf_db_query($sql, $app->db());
             if (!$res) {
                 trigger_error(xf_db_error($app->db()), E_USER_ERROR);
             }
         }
     }
     $table_keys =& $table->keys();
     //Next we have to go through all of the key fields in the metadata table ane make sure that they
     // appear in the subject table primary keys.
     foreach ($this->getKeyColumns($tablename, false) as $field) {
         if (!isset($table_keys[$field['Field']])) {
             $updatePrimaryKey = true;
             $sql = "alter table `{$md_tablename}` drop column `{$field['Field']}`";
             $res = xf_db_query($sql, $app->db());
             if (!$res) {
                 trigger_error(xf_db_error($app->db()), E_USER_ERROR);
             }
         }
     }
     // If the primary key needed to be updated, we will update it now.
     if ($updatePrimaryKey) {
         // The primary key needs to be updated
         $sql = "drop primary key";
         @xf_db_query($sql, $app->db());
         $sql = "alter table `{$md_tablename}` add primary key (`" . implode('`,`', array_keys($table->keys())) . "`)";
         $res = xf_db_query($sql, $app->db());
         if (!$res) {
             trigger_error(xf_db_error($app->db()), E_USER_ERROR);
         }
     }
     // Now we need to make sure that all of the prescribed meta fields are
     // in the metadata field.
     $fielddefs = $this->loadMetadataFieldDefs($tablename);
     $cols = $this->getColumns($tablename, false);
     foreach ($fielddefs as $field) {
         if (!isset($cols[$field['Field']])) {
             $default = @$field['Default'] ? " DEFAULT {$field['Default']}" : '';
             $sql = "alter table `{$md_tablename}` add column `{$field['Field']}` {$field['Type']}{$default}";
             $res = xf_db_query($sql, $app->db());
             if (!$res) {
                 trigger_error(xf_db_error($app->db()), E_USER_ERROR);
             }
         }
     }
     return true;
 }
开发者ID:minger11,项目名称:Pipeline,代码行数:79,代码来源:MetadataTool.php

示例5: findMatchingSnapshots

 /**
  * Returns an array of history ids of history records that match the 
  * given query.
  */
 function findMatchingSnapshots($record, $query, $idsOnly = true)
 {
     $app =& Dataface_Application::getInstance();
     $htablename = $record->_table->tablename . '__history';
     if (!Dataface_Table::tableExists($htablename)) {
         return array();
     }
     $keys = $record->strvals(array_keys($record->_table->keys()));
     foreach ($keys as $key => $val) {
         $query[$key] = '=' . $val;
     }
     if ($idsOnly) {
         $qbuilder = new Dataface_QueryBuilder($htablename, $query);
         $sql = $qbuilder->select(array('history__id'), $query);
         $res = xf_db_query($sql, df_db());
         $ids = array();
         while ($row = xf_db_fetch_row($res)) {
             $ids[] = $row[0];
         }
         @xf_db_free_result($res);
         return $ids;
     } else {
         return df_get_records_array($htablename, $query);
     }
 }
开发者ID:minger11,项目名称:Pipeline,代码行数:29,代码来源:HistoryTool.php

示例6: getBlackListed

 function getBlackListed($emails)
 {
     if (!Dataface_Table::tableExists('dataface__email_blacklist')) {
         $this->createEmailTables(null, null);
     }
     if (!is_array($emails)) {
         $emails = array($emails);
     }
     $res = mysql_query("select email from dataface__email_blacklist where email in ('" . implode("','", array_map('addslashes', $emails)) . "')", df_db());
     $out = array();
     if (!$res) {
         trigger_error(mysql_error(df_db()), E_USER_ERROR);
     }
     while ($row = mysql_fetch_row($res)) {
         $out[] = $row[0];
     }
     @mysql_free_result($res);
     return $out;
 }
开发者ID:promoso,项目名称:HVAC,代码行数:19,代码来源:email.php

示例7: createRegistrationTable

 /**
  * Creates a table to hold the temporary user registrations.
  */
 function createRegistrationTable()
 {
     if (!Dataface_Table::tableExists('dataface__registrations', false)) {
         $sql = "create table `dataface__registrations` (\n\t\t\t\tregistration_code varchar(32) not null,\n\t\t\t\tregistration_date timestamp not null,\n\t\t\t\tregistration_data longtext not null,\n\t\t\t\tprimary key (registration_code)) ENGINE=InnoDB DEFAULT CHARSET=utf8";
         // registration_code stores an md5 code used to identify the registration
         // registration_date is the date that the registration was made
         // registration_data is a serialized array of the data from getValues()
         // on the record.
         $res = xf_db_query($sql, df_db());
         if (!$res) {
             throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
         }
     }
     return true;
 }
开发者ID:minger11,项目名称:Pipeline,代码行数:18,代码来源:register.php

示例8: submitTranslation

 function submitTranslation(&$record, $params = array())
 {
     if (!Dataface_Table::tableExists('dataface__translation_submissions', false)) {
         $this->createTranslationSubmissionsTable();
     }
     $trec = new Dataface_Record('dataface__translation_submissions', array());
     $trec->setValues($params);
     $trec->save();
 }
开发者ID:Zunair,项目名称:xataface,代码行数:9,代码来源:TranslationTool.php


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