public function dataLoad($models = null) {

        if (!empty($models)) {
            if (!is_array($models)) $models = array($models);
        } else {
            $models = array_keys($this->_structures);
        }

        $data_dir = $this->_storagePath . 'data/';
        foreach ($models as $model) {
            $model     = ucfirst($model);
            $file_name = $data_dir . strtolower($model) . '.yml';
            if (!isset($this->_structures[$model]) || !is_file($file_name)) continue;
            $data = Yaml::parse(file_get_contents($file_name));
            if (!is_array($data)) continue;

            QC::executeSQL('SET FOREIGN_KEY_CHECKS=0');
            QC::executeSQL('TRUNCATE `' . $this->_structures[$model]['table'] . '`');
            QC::create($this->_structures[$model]['table'])->insert($data)->execute();
        }
    }
public function dataLoad($models = null) {

        if (!empty($models)) {
            if (!is_array($models)) $models = array($models);
        } else {
            $models = array_keys($this->_structures);
        }

        $data_dir = $this->_storagePath . 'data/';
        foreach ($models as $model) {
            $model     = ucfirst($model);
            $file_name = $data_dir . strtolower($model) . '.yml';
            if (!isset($this->_structures[$model]) || !is_file($file_name)) continue;
            $data = Yaml::parse(file_get_contents($file_name));
            if (!is_array($data)) continue;

            QC::executeSQL('SET FOREIGN_KEY_CHECKS=0');
            QC::executeSQL('TRUNCATE `' . $this->_structures[$model]['table'] . '`');
            QC::create($this->_structures[$model]['table'])->insert($data)->execute();
        }
    }
public function dataLoad ( $ models = null ) { if ( ! empty ( $ models ) ) { if ( ! is_array ( $ models ) ) $ models = array ( $ models ) ; } else { $ models = array_keys ( $ this -> _structures ) ; } $ data_dir = $ this -> _storagePath . 'data/' ; foreach ( $ models as $ model ) { $ model = ucfirst ( $ model ) ; $ file_name = $ data_dir . strtolower ( $ model ) . '.yml' ; if ( ! isset ( $ this -> _structures [ $ model ] ) || ! is_file ( $ file_name ) ) continue ; $ data = Yaml :: parse ( file_get_contents ( $ file_name ) ) ; if ( ! is_array ( $ data ) ) continue ; QC :: executeSQL ( 'SET FOREIGN_KEY_CHECKS=0' ) ; QC :: executeSQL ( 'TRUNCATE `' . $ this -> _structures [ $ model ] [ 'table' ] . '`' ) ; QC :: create ( $ this -> _structures [ $ model ] [ 'table' ] ) -> insert ( $ data ) -> execute ( ) ; } }
Load data from YML files into database with replacing
@param string|array $models
Load data from YML files into database with replacing