Checks if all data and options are in order prior to exporting.

@return  MysqlImporter  Method supports chaining.

@since   1.0
@throws  \Exception if an error is encountered.
322927
public function check()
	{
		// Check if the db connector has been set.
		if (!($this->db instanceof MysqlDriver))
		{
			throw new \Exception('Database connection wrong type.');
		}

		// Check if the tables have been specified.
		if (empty($this->from))
		{
			throw new \Exception('ERROR: No Tables Specified');
		}

		return $this;
	}
677066
protected function beforeTable()
    {
        $hasMassActions = $this->hasMassActions();
        $filters        = $this->filterAdapter->getFilters();

        $hasColumnFilter = $this->hasColumnFilter();
        $params          = [];
        if (!$hasMassActions and ! $this->searchable and empty($this->selects) and ! $filters and ! $hasColumnFilter) {
            return '';
        }


        if (!empty($this->selects)) {
            array_set($params, 'selects', implode('', $this->selects));
        }
        array_set($params, 'searchable', $this->searchable);
        if ($this->searchable) {
            $value = (($value = $this->getGlobalSearchValue()) !== false) ? $value : '';
            array_set($params, 'search', $value);
        }
        $result = event(strtolower(class_basename($this->datatable)) . '.datatables.top.center', [&$return]);
        if (isset($result[0])) {
            array_set($params, 'datatables_top_center', $result[0]);
        }

        if (!is_null($this->rightCtrls)) {
            array_set($params, 'rightCtrls', $this->rightCtrls);
        }

        if (empty($filters) and ! is_null($this->datatable)) {
            $list = $this->datatable->getFilters();
            foreach ($list as $filter) {
                $this->filterAdapter->add($filter);
            }
            $filters = $this->filterAdapter->getFilters();
        }

        if ($hasColumnFilter) {
            array_set($params, 'columnFilter', $this->getColumnFilterAdapter());
        }
        if ($filters) {
            array_set($params, 'filters', $filters);
        }

        if ($hasMassActions) {
            array_set($params, 'massActions', $this->massActions);
        }
        return view('datatables-helpers::before', $params)->render();
    }
166567
private function insert()
    {
        $insert = $this->dsql();

        // Performs the actual database changes. Throw exception if problem occurs
        foreach ($this->elements as $name => $f) {
            if ($f instanceof Field) {
                if (!$f->editable() && !$f->system()) {
                    continue;
                }
                if (!isset($this->dirty[$name]) && $f->defaultValue() === null) {
                    continue;
                }

                $f->updateInsertQuery($insert);
            }
        }
        $this->hook('beforeInsert', array(&$insert));
        //delayed is not supported by INNODB, but what's worse - it shows error.
        //if($this->_save_as===false)$insert->option_insert('delayed');
        $id = $insert->insert();
        if ($id == 0) {
            // no auto-increment column present
            $id = $this->get($this->id_field);

            if ($id === null && $this->_save_as !== false) {
                throw $this->exception('Please add auto-increment ID column to your table or specify ID manually');
            }
        }
        $res = $this->hook('afterInsert', array($id));
        if ($res === false) {
            return $this;
        }

        if ($this->_save_as === false) {
            return $this->unload();
        }
        if ($this->_save_as) {
            $this->unload();
        }
        $o = $this->_save_as ?: $this;

        if ($this->fast && !$this->_save_as) {
            $this[$this->id_field] = $this->id = $id;

            return $this;
        }
        $res = $o->tryLoad($id);
        if (!$res->loaded()) {
            throw $this->exception('Saved model did not match conditions. Save aborted.');
        }

        return $res;
    }
346880
public function getMaximumAmount()
    {
        if (!isset($this->_issuerData))
            throw new Exception("Issuer must be selected first");
        if (!isset($this->_country))
            throw new Exception("Country must be selected first");
        foreach ($this->_issuerData["Countries"] as $country) {
            if ($this->_country == $country["CountryCode"]) {
                return intval($country["MaximumAmount"]);
            }
        }
    }
376212
public function compile()
    {
        // check for the bare minimum
        if ($this->table === false || $this->type === false) {
            throw (new \Exception('Query compilation failure: missing table or type'));
        }
        switch ($this->type) {
            case 'UPDATE':
                return $this->generateUPDATEStatement();
            case 'INSERT':
                return $this->generateINSERTStatement();
            case 'DELETE':
                return $this->generateDELETEStatement();
            default:
                return $this->generateSELECTStatement();
        }
    }
9393
public function get()
    {
        $m = $this->model;
        if (!$m) {
            throw $this->exception('Specify model_class or define your method handlers');
        }

        if ($m->loaded()) {
            if (!$this->allow_list_one) {
                throw $this->exception('Loading is not allowed');
            }

            return $this->outputOne($m->get());
        }

        if (!$this->allow_list) {
            throw $this->app->exception('Listing is not allowed');
        }

        return $this->outputMany($m->setLimit(100)->getRows());
    }
391939
public function check()
	{
		// Check if the db connector has been set.
		if (!($this->db instanceof PgsqlDriver))
		{
			throw new \Exception('Database connection wrong type.');
		}

		// Check if the tables have been specified.
		if (empty($this->from))
		{
			throw new \Exception('ERROR: No Tables Specified');
		}

		return $this;
	}
1325811
public function startImport()
    {
        if ($this->_targetModel instanceof \MUtil_Model_ModelAbstract) {
            // No multiOptions as a new items can be created during import
            $fields = array(
                'gap_id_attended_by', 'gap_id_referred_by', 'gap_id_activity',  'gap_id_procedure', 'gap_id_location',
                );
            foreach ($fields as $name) {
                $this->_targetModel->del($name, 'multiOptions');
            }
        }

        return parent::startImport();
    }
155985
protected function _setLimit()
    {
        if (
            is_null($this->_sql->getLimit()) ||
            intval($this->_sql->getLimit()) < 1
        ) {
            return $this;
        }

        if ($this->_sql->getOffset() > 0) {
            return $this->_setLimitWithOffset();
        }
        return  $this->_setSimpleLimit();
    }
900242
private function getCurrentExporter()
    {
        if ($this->hasRequestParameter('exportHandler')) {
            $exportHandler = $_REQUEST['exportHandler'];//allow method "GET"
            if (class_exists($exportHandler)
                && in_array('tao_models_classes_export_ExportHandler', class_implements($exportHandler))
            ) {
                return new $exportHandler();
            } else {
                throw new common_Exception('Unknown or incompatible ExporterHandler: \'' . $exportHandler . '\'');
            }
        } else {
            return current($this->getAvailableExportHandlers());
        }
    }
1195374
public function getSupportedCharsets()
    {
        if ($this->supportedCharsets === null) {
            $supportedCharsets = [];
            $rs = $this->executeQuery('SHOW CHARACTER SET');
            while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) {
                if (!isset($row['Charset']) || !isset($row['Default collation'])) {
                    throw new Exception(t('Unrecognized result of the "%s" database query.', 'SHOW CHARACTER SET'));
                }
                $supportedCharsets[strtolower($row['Charset'])] = strtolower($row['Default collation']);
            }
            $this->supportedCharsets = $supportedCharsets;
        }

        return $this->supportedCharsets;
    }
782813
public function getExporter()
	{
		// Derive the class name from the driver.
		$class = '\\Joomla\\Database\\' . ucfirst($this->name) . '\\' . ucfirst($this->name) . 'Exporter';

		// Make sure we have an exporter class for this driver.
		if (!class_exists($class))
		{
			// If it doesn't exist we are at an impasse so throw an exception.
			throw new Exception\UnsupportedAdapterException('Database Exporter not found.');
		}

		/** @var $o DatabaseExporter */
		$o = new $class;
		$o->setDbo($this);

		return $o;
	}
737706
final public function begin()
    {
        if (!$this->pdo) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_DATABASE_ERROR);
        }
        if ($this->_begintransaction) {
            throw new Exception("已经开启了一个事务，请勿重新开启", Exception::CODE_DATABASE_ERROR);
        }
        $this->pdo->beginTransaction();
        $this->_begintransaction = true;
        return $this;
    }
528288
private function getPreparedMultiSelect()
    {
        if (is_null($this->preparedMultiSelect)) {
            $this->preparedMultiSelect = $this->getServer()
                ->select()
                ->select([$this->keyColumnName, $this->valueColumnName])
                ->from($this->tableName)
                ->where('AND')
                ->expr($this->keyColumnName, 'in', ':ids')
                ->begin('OR')
                ->expr($this->expireColumnName, '=', ':zero')
                ->expr($this->expireColumnName, '>', ':expire')
                ->end();
        }

        return $this->preparedMultiSelect;
    }
643986
public function getAvailableImportHandlers()
    {
        $returnValue = parent::getAvailableImportHandlers();

        foreach (array_keys($returnValue) as $key) {
            if ($returnValue[$key] instanceof \tao_models_classes_import_CsvImporter) {
                $importer = new CsvImporter();
                $importer->setValidators($this->getValidators());
                $returnValue[$key] = $importer;
            }
        }

        return $returnValue;
    }
211760
private function getOrderNormalizer()
    {
        return function(Options $options, $order) {
            foreach ($order as $field => $sort) {
                if (!is_string($sort) || !is_string($field) || !in_array(strtolower($sort), ['asc', 'desc'])) {
                    throw new Exception(
                        'Order value should be an array of string (["field" => $key]), got '.gettype($sort)
                    );
                }
            }

            return $order;
        };
    }
1014594
public function performCheck()
    {
        try {
            $supported = false;
            foreach ($this->connection->fetchAll('show engines') as $engine) {
                $engine = array_change_key_case($engine, CASE_LOWER);
                if (isset($engine['engine']) && strtolower($engine['engine']) == 'innodb') {
                    $supported = true;
                    break;
                }
            }
            if ($supported) {
                $result = new PreconditionResult(PreconditionResult::STATE_PASSED);
            } else {
                $result = new PreconditionResult(PreconditionResult::STATE_FAILED, t('Your MySQL database does not support InnoDB database tables. These are required.'));
            }
        } catch (Exception $x) {
            $result = new PreconditionResult(PreconditionResult::STATE_FAILED, $x->getMessage());
        }

        return $result;
    }