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


PHP CsviHelper::getPrimaryKey方法代码示例

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


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

示例1: __construct

 /**
  * Table constructor
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param 		$db	object	A database connector object
  * @return
  * @since 		3.0
  */
 public function __construct($db)
 {
     $jinput = JFactory::getApplication()->input;
     $template = $jinput->get('template', null, null);
     // Find which table we are importing
     $tbl = $template->get('custom_table');
     // Find the primare key for this table
     $pk = CsviHelper::getPrimaryKey($tbl);
     parent::__construct('#__' . $tbl, $pk, $db);
 }
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:22,代码来源:custom_table.php

示例2: getAvailableFieldsSingle

 /**
  * Import the available fields in steps
  *
  * @copyright
  * @author 		RolandD
  * @todo
  * @see
  * @access 		public
  * @param
  * @return
  * @since 		3.5
  */
 public function getAvailableFieldsSingle()
 {
     $db = JFactory::getDbo();
     $jinput = JFactory::getApplication()->input;
     $queries = array();
     // Load the session data
     $session = JFactory::getSession();
     $option = $jinput->get('option');
     $csvilog = unserialize($session->get($option . '.csvilog'));
     $lines = unserialize($session->get($option . '.linesprocessed'));
     if (empty($lines)) {
         $lines = 0;
     }
     $lines++;
     // Set the line number
     $csvilog->setLinenumber($lines);
     $errors = false;
     $process = false;
     // Load a table to index
     while (!$process) {
         $query = $db->getQuery(true);
         $query->select('template_table, component')->from('#__csvi_template_tables')->where('indexed = 0')->where($db->qn('template_table') . ' != ' . $db->qn('template_type_name'))->group($db->qn('template_table'));
         $db->setQuery($query, 0, 1);
         $table = $db->loadObject();
         if (is_object($table)) {
             // Set the table name
             $showtable = $table->template_table;
             // Check if the table exists
             $tables = $db->getTableList();
             if (in_array($db->getPrefix() . $showtable, $tables)) {
                 // Get the primary key for the table
                 $primarykey = CsviHelper::getPrimaryKey($showtable);
                 $fields = $this->DbFields($showtable, true);
                 if (is_array($fields)) {
                     $process = true;
                     // Process all fields
                     foreach ($fields as $name => $value) {
                         // Check if the field is a primary field
                         if ($primarykey == $name) {
                             $primary = 1;
                         } else {
                             $primary = 0;
                         }
                         if ($name) {
                             $q = "INSERT IGNORE INTO " . $db->qn('#__csvi_available_fields') . " VALUES (" . "0," . $db->q($name) . "," . $db->q($name) . "," . $db->q($value) . "," . $db->q($table->component) . "," . $db->q($primary) . ")";
                             $db->setQuery($q);
                             if (!$db->query()) {
                                 $errors = true;
                             }
                         }
                     }
                     // foreach
                     // Check for any errors
                     if (!$errors) {
                         $jinput->set('updatetable', $showtable);
                         $csvilog->AddStats('added', JText::sprintf('COM_CSVI_AVAILABLE_FIELDS_HAVE_BEEN_ADDED', $showtable));
                     } else {
                         $csvilog->AddStats('error', JText::_('COM_CSVI_AVAILABLE_FIELDS_HAVE_NOT_BEEN_ADDED'));
                     }
                 }
                 // is_array
             }
             // Set the table to indexed
             $query = $db->getQuery(true);
             $query->update('#__csvi_template_tables')->set('indexed = 1')->where('template_table = ' . $db->quote($showtable))->where('component = ' . $db->quote($table->component));
             $db->setQuery($query);
             $db->query();
             // Assign the tables to the session
             $session->set($option . '.linesprocessed', serialize($lines));
             $continue = true;
         } else {
             $jinput->set('csvilog', $csvilog);
             // Clear the session
             $session->set($option . '.csvilog', serialize('0'));
             $session->set($option . '.linesprocessed', serialize('0'));
             // Set the run ID
             $jinput->set('run_id', $csvilog->getId());
             $continue = false;
             $process = true;
         }
         // Assign the log to the session
         $session->set($option . '.csvilog', serialize($csvilog));
     }
     return $continue;
 }
开发者ID:alesconti,项目名称:FF_2015,代码行数:97,代码来源:availablefields.php


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