Exemplo n.º 1
0
 /**
  * Checks whether a table exists.
  *
  * @param  string $name
  * @return boolean
  * @access private
  */
 function _tableExists($name)
 {
     parent::query('SHOW TABLES');
     while ($field = $this->_fetchFirstField()) {
         if ($field == $name) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Creates a new table and adds it to the
  * appropriate MRG_MyISAM table.
  *
  * @param  string  $name
  * @param  string  $type
  * @param  integer $month
  * @param  integer $year
  * @access private
  */
 function _newTable($name, $type, $month, $year)
 {
     $mergeTableExists = false;
     $tablePrefix = $name . '_';
     $tables = array();
     for ($i = $month; $i <= 12; $i++) {
         parent::query(sprintf($type == 'accesslog' ? $this->accesslogSchema : $this->visitorsSchema, '', 'IF NOT EXISTS', $tablePrefix . $year . sprintf('%02d', $i), 'DELAY_KEY_WRITE=1'));
     }
     parent::query('SHOW TABLES');
     while ($row = $this->fetchRow(false)) {
         if (strstr($row[0], $tablePrefix)) {
             $tables[] = $row[0];
         } else {
             if ($row[0] == $name) {
                 $mergeTableExists = true;
             }
         }
     }
     sort($tables);
     $tables = implode(',', $tables);
     if ($mergeTableExists) {
         parent::query(sprintf('ALTER TABLE %s UNION(%s)', $name, $tables));
     } else {
         $this->createMergeTable($name, $type, $tables);
     }
 }