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


PHP BackWPup_Job::get_restart_time方法代码示例

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


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

示例1: job_run

 /**
  * Dumps the Database
  *
  * @param $job_object BackWPup_Job
  *
  * @return bool
  */
 public function job_run(BackWPup_Job $job_object)
 {
     $job_object->substeps_todo = 1;
     if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
         $job_object->log(sprintf(__('%d. Try to backup database …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
     }
     //build filename
     if (empty($job_object->steps_data[$job_object->step_working]['dbdumpfile'])) {
         $job_object->steps_data[$job_object->step_working]['dbdumpfile'] = $job_object->generate_filename($job_object->job['dbdumpfile'], 'sql') . $job_object->job['dbdumpfilecompression'];
     }
     try {
         //Connect to Database
         $sql_dump = new BackWPup_MySQLDump(array('dumpfile' => BackWPup::get_plugin_data('TEMP') . $job_object->steps_data[$job_object->step_working]['dbdumpfile']));
         if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
             $job_object->log(sprintf(__('Connected to database %1$s on %2$s', 'backwpup'), DB_NAME, DB_HOST));
         }
         //Exclude Tables
         foreach ($sql_dump->tables_to_dump as $key => $table) {
             if (in_array($table, $job_object->job['dbdumpexclude'], true)) {
                 unset($sql_dump->tables_to_dump[$key]);
             }
         }
         //set steps must done
         $job_object->substeps_todo = count($sql_dump->tables_to_dump);
         if ($job_object->substeps_todo == 0) {
             $job_object->log(__('No tables to backup.', 'backwpup'), E_USER_WARNING);
             unset($sql_dump);
             return TRUE;
         }
         //dump head
         if (!isset($job_object->steps_data[$job_object->step_working]['is_head'])) {
             $sql_dump->dump_head(TRUE);
             $job_object->steps_data[$job_object->step_working]['is_head'] = TRUE;
         }
         //dump tables
         $i = 0;
         foreach ($sql_dump->tables_to_dump as $table) {
             if ($i < $job_object->substeps_done) {
                 $i++;
                 continue;
             }
             if (empty($job_object->steps_data[$job_object->step_working]['tables'][$table])) {
                 $num_records = $sql_dump->dump_table_head($table);
                 $job_object->steps_data[$job_object->step_working]['tables'][$table] = array('start' => 0, 'length' => 1000);
                 if ($job_object->is_debug()) {
                     $job_object->log(sprintf(__('Backup database table "%s" with "%s" records', 'backwpup'), $table, $num_records));
                 }
             }
             $while = true;
             while ($while) {
                 $dump_start_time = microtime(TRUE);
                 $done_records = $sql_dump->dump_table($table, $job_object->steps_data[$job_object->step_working]['tables'][$table]['start'], $job_object->steps_data[$job_object->step_working]['tables'][$table]['length']);
                 $dump_time = microtime(TRUE) - $dump_start_time;
                 if (empty($dump_time)) {
                     $dump_time = 0.01;
                 }
                 if ($done_records < $job_object->steps_data[$job_object->step_working]['tables'][$table]['length']) {
                     //that is the last chunk
                     $while = FALSE;
                 }
                 $job_object->steps_data[$job_object->step_working]['tables'][$table]['start'] = $job_object->steps_data[$job_object->step_working]['tables'][$table]['start'] + $done_records;
                 // dump time per record and set next length
                 $length = ceil($done_records / $dump_time * $job_object->get_restart_time());
                 if ($length > 25000 || 0 >= $job_object->get_restart_time()) {
                     $length = 25000;
                 }
                 if ($length < 1000) {
                     $length = 1000;
                 }
                 $job_object->steps_data[$job_object->step_working]['tables'][$table]['length'] = $length;
                 $job_object->do_restart_time();
             }
             $sql_dump->dump_table_footer($table);
             $job_object->substeps_done++;
             $i++;
             $job_object->update_working_data();
         }
         //dump footer
         $sql_dump->dump_footer();
         unset($sql_dump);
     } catch (Exception $e) {
         $job_object->log($e->getMessage(), E_USER_ERROR, $e->getFile(), $e->getLine());
         unset($sql_dump);
         return FALSE;
     }
     $filesize = filesize(BackWPup::get_plugin_data('TEMP') . $job_object->steps_data[$job_object->step_working]['dbdumpfile']);
     if (!is_file(BackWPup::get_plugin_data('TEMP') . $job_object->steps_data[$job_object->step_working]['dbdumpfile']) || $filesize < 1) {
         $job_object->log(__('MySQL backup file not created', 'backwpup'), E_USER_ERROR);
         return FALSE;
     } else {
         $job_object->additional_files_to_backup[] = BackWPup::get_plugin_data('TEMP') . $job_object->steps_data[$job_object->step_working]['dbdumpfile'];
         $job_object->log(sprintf(__('Added database dump "%1$s" with %2$s to backup file list', 'backwpup'), $job_object->steps_data[$job_object->step_working]['dbdumpfile'], size_format($filesize, 2)));
     }
//.........这里部分代码省略.........
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:101,代码来源:class-jobtype-dbdump.php


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