示例#1
0
 /**
  * Construct and set the controller's properties from the posted form.
  */
 public function __construct()
 {
     global $supported;
     $this->handleInfoForm();
     $this->ex = new ExportModel();
     $this->ex->controller = $this;
     $this->ex->setConnection($this->dbInfo['dbhost'], $this->dbInfo['dbuser'], $this->dbInfo['dbpass'], $this->dbInfo['dbname']);
     $this->ex->prefix = '';
     // That's not sexy but it gets the job done :D
     $lcClassName = strtolower(get_class($this));
     $hasDefaultPrefix = !empty($supported[$lcClassName]['prefix']);
     if (isset($this->dbInfo['prefix'])) {
         if ($this->dbInfo['prefix'] === 'PACKAGE_DEFAULT') {
             if ($hasDefaultPrefix) {
                 $this->ex->prefix = $supported[$lcClassName]['prefix'];
             }
         } else {
             $this->ex->prefix = $this->dbInfo['prefix'];
         }
     }
     $this->ex->destination = $this->param('dest', 'file');
     $this->ex->destDb = $this->param('destdb', null);
     $this->ex->testMode = $this->param('test', false);
     /**
      * Selective exports
      * 1. Get the comma-separated list of tables and turn it into an array
      * 2. Trim off the whitespace
      * 3. Normalize case to lower
      * 4. Save to the ExportModel instance
      */
     $restrictedTables = $this->param('tables', false);
     if (!empty($restrictedTables)) {
         $restrictedTables = explode(',', $restrictedTables);
         if (is_array($restrictedTables) && !empty($restrictedTables)) {
             $restrictedTables = array_map('trim', $restrictedTables);
             $restrictedTables = array_map('strtolower', $restrictedTables);
             $this->ex->restrictedTables = $restrictedTables;
         }
     }
 }