get sql files
@return Finder
177764
public function getSqlFiles()
    {
        $sqlFinder = $this->getFinder();

        $files = $sqlFinder->files()
            ->in($this->sqlFilesDir)
            ->name(self::PATTERN)
            ->sort($this->sort())
        ;

        return $files;
    }
166368
public function getSql() {
        $sql = "CREATE TABLE IF NOT EXISTS {$this->getTable()} (";
        $column = $this->_data;
        if (!empty($this->primaryKey)) {
            $column[] = "PRIMARY KEY (`{$this->primaryKey}`)";
        }
        foreach ($this->checks as $key => $item) {
            $column[] = (!is_integer($key) ? "CONSTRAINT `{$key}` " : null)." CHECK ({$item})";
        }
        foreach ($this->index as $key => $item) {
            $column[] = (count($item) > 2 ? 'UNIQUE ': null). "INDEX `{$key}` (`{$item[0]}` {$item['1']})";
        }
        foreach ($this->foreignKey as $key => $item) {
            $column[] = "CONSTRAINT `{$key}` FOREIGN KEY (`{$item[0]}`) REFERENCES `{$item[1]}` (`{$item[2]}`) ON DELETE {$item[2]} ON UPDATE {$item[3]}";
        }
        $sql .= implode(',', $column).") ENGINE={$this->engine}";
        if ($this->aiBegin > 1) {
            $sql .= ' AUTO_INCREMENT='.$this->aiBegin;
        }
        return $sql." DEFAULT CHARSET={$this->charset} COMMENT='{$this->comment}';";
    }
244946
protected function getFileQuery()
    {
        $table = DataObject::singleton(File::class)->baseTable();
        // Select all records which have a Filename value, but not FileFilename.
        /** @skipUpgrade */
        return File::get()
            ->exclude('ClassName', [Folder::class, 'Folder'])
            ->filter('FileFilename', array('', null))
            ->where(sprintf(
                '"%s"."Filename" IS NOT NULL AND "%s"."Filename" != \'\'',
                $table,
                $table
            )) // Non-orm field
            ->alterDataQuery(function (DataQuery $query) use ($table) {
                return $query->addSelectFromTable($table, ['Filename']);
            });
    }
136967
public function getFinder()
    {
        if (null === $this->finder) {
            $this->finder = new Finder();
            $this->finder->files();
        }

        return $this->finder;
    }
33039
private static function _get_databases(): ?databases
  {
    if ( self::check() ){
      if ( !self::$databases_obj && ($db = self::_get_db()) ){
        self::$databases_obj = new databases($db);
      }
      return self::$databases_obj;
    }
    return null;
  }
252325
public static function get()
    {
        $db = Database::connection();
        $treeID = $db->fetchColumn('select Trees.treeID from TreeTypes inner join Trees on TreeTypes.treeTypeID = Trees.treeTypeID where TreeTypes.treeTypeHandle = ?', ['file_manager']);

        return $treeID ? Tree::getByID($treeID) : null;
    }
21215
function GetTables()
    {
        $tables = array();
        $sql = new Sql\Builder($this);
        $tbl = $sql->Table('information_schema.tables', array('TABLE_SCHEMA', 'TABLE_NAME'));
        $cond = $sql->Equals($tbl->Field('TABLE_SCHEMA'), $sql->Value($this->dbName));
        $what = $sql->SelectList($tbl->Field('TABLE_NAME'));

        $select = $sql->Select(true, $what, $tbl, $cond);
        $reader = $this->ExecuteQuery((string) $select);
        while ($reader->Read())
        {
            $tables[] = $reader->ByIndex(0);
        }
        return $tables;
    }
545328
protected function getCurrentSQL() {
        $cloneQuery = clone $this->query;
        $cloneQuery = $this->loadElements($cloneQuery);
        return $cloneQuery->compile();
    }
100503
protected function getDb()
    {
        return \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
    }
55506
public function findAll() {
        $sql = $this->getSql();
        $params = array_merge($this->whereParams(), $this->having_params);
        $connection = Pool::get(Connection::class);
        try {
            $data = $connection->query($sql, $params, $this->cache);
            Pool::release($connection);
        } catch (\RuntimeException $e) {
            Pool::release($connection);
            throw $e;
        } catch (\Error $e) {
            Pool::release($connection);
            throw $e;
        }
        if ($this->clazz) {
            $results = [];
            l:
            /* @var $item */
            foreach ($data as $item) {
                $clazz = $this->clazz;
                $result = new $clazz;
                foreach ($this->subRecord as $pre => $sub) {
                    $pre .= "_";
                    $values = [];
                    $length = strlen($pre);
                    foreach ($item as $key => $value) {
                        if (strpos($key, $pre) === 0) {
                            unset($item[ $key ]);
                            $key = substr($key, $length);
                            $values[ $key ] = $value;
                        }
                    }
                    $clazz = $sub[ 'class' ];
                    $field = $sub[ 'field' ];
                    /* @var $subRecord Record */
                    $subRecord = new $clazz;
                    $subRecord->fromDbData($values);
                    if ($sub[ 'all_do' ]) {
                        $call = $sub[ 'all_do' ];
                        $call($subRecord);
                    }
                    $result->$field = $subRecord;
                }
                if ($result instanceof Record) {
                    $result->fromDbData($item);
                } else {
                    foreach ($item as $key => $value) {
                        $result->$key = $value;
                    }
                }
                $is_remove = false;
                if ($this->all_do) {
                    foreach ($this->all_do as $do) {
                        $return = $result->$do();
                        if ($return === self::REMOVED) {
                            $is_remove = true;
                            break;
                        }
                    }
                }
                if ($is_remove) {
                    continue;
                }
                if ($this->each) {
                    foreach ($this->each as $each) {
                        $return = $each($result);
                        if ($return === self::REMOVED) {
                            $is_remove = true;
                            break;
                        }
                    }
                }
                if ($is_remove) {
                    continue;
                }
                if ($this->to_array && $result instanceof Record) {
                    $result = $result->toArray($this->to_array, $this->to_array_contain);
                }
                $results[] = $result;
            }
            return $results;
        }
        return $data;
    }
1024252
public static function objects()
    {
        //====================================================================//
        // Check if Object Manager is Overriden
        if (self::local() instanceof ObjectsProviderInterface) {
            return self::local()->objects();
        }
        $objectsList = array();
        //====================================================================//
        // Safety Check => Verify Objects Folder Exists
        $path = self::getLocalPath().'/Objects';
        if (!is_dir($path)) {
            return $objectsList;
        }
        //====================================================================//
        // Scan Local Objects Folder
        $scan = scandir($path, 1);
        if (false == $scan) {
            return $objectsList;
        }
        //====================================================================//
        // Scan Each File in Folder
        $files = array_diff($scan, array('..', '.', 'index.php', 'index.html'));
        foreach ($files as $filename) {
            //====================================================================//
            // Verify Filename is a File (Not a Directory)
            if (!is_file($path.'/'.$filename)) {
                continue;
            }
            //====================================================================//
            // Extract Class Name
            $className = pathinfo($path.'/'.$filename, PATHINFO_FILENAME);
            //====================================================================//
            // Verify ClassName is a Valid Object File
            if (false == self::validate()->isValidObject($className)) {
                continue;
            }
            $objectsList[] = $className;
        }

        return $objectsList;
    }
658103
public function findBySql($sql,$params=array())
	{
		Yii::trace(get_class($this).'.findBySql()','system.db.ar.CActiveRecord');
		$this->beforeFind();
		if(($criteria=$this->getDbCriteria(false))!==null && !empty($criteria->with))
		{
			$this->resetScope(false);
			$finder=$this->getActiveFinder($criteria->with);
			return $finder->findBySql($sql,$params);
		}
		else
		{
			$command=$this->getCommandBuilder()->createSqlCommand($sql,$params);
			return $this->populateRecord($command->queryRow());
		}
	}
799019
public function getLogFiles()
    {
        $files = new Finder();
        $files->files()->in(LOG_DIR)->name('*.log')->sortByModifiedTime();
        $logs = array();
        /** @var \SplFileInfo $file */
        foreach ($files as $file) {
            $size = $file->getSize() / 8 / 1024;
            $time = date('c', $file->getMTime());
            $dateTime = new \DateTime($time);
            if (!isset($logs[$dateTime->format('Y')])) {
                $logs[$dateTime->format('Y')] = [];
            }
            $logs[$dateTime->format('Y')][$dateTime->format('m')][$time] = [
                'filename' => $file->getFilename(),
                'size' => round($size, 3),
            ];
            krsort($logs[$dateTime->format('Y')][$dateTime->format('m')]);
            krsort($logs[$dateTime->format('Y')]);
        }
        return $logs;
    }
1272594
public function findAll()
    {
        $ret = $this->conn()->selectCollection($this->table_name)->find($this->where, $this->field);
        if ($this->limit) {
            $ret->limit($this->limit)->skip($this->skip);
        }
        if ($this->orderby) {
            $ret->sort($this->orderby);
        }

        $this->sql = array(
                     'table'=> $this->table_name,
                     'query'=>$this->where,
                     'field'=> $this->field,
                     'limit'=> $this->limit,
                     'skip'=> $this->skip,
                   );
        $this->_clear_var();
        return $ret;
    }
1297821
public function get($columns = ['*'])
    {
        return $this->select($columns)->map(function ($row) {
            return Finder::createStore($row);
        });
    }
109623
public function get()
    {
        $sql = "SELECT * FROM `$this->_table` ";

        $this->_param_list = array();

        if (!empty($this->_where_list)) {
            $sql .= "WHERE ";
            $first = true;
            foreach ($this->_where_list as $field_name => $field_settings) {
                $type          = isset($field_settings['type']) ? $field_settings['type'] : false;
                $field_value   = $field_settings['value'];
                $field_connect = isset($field_settings['op']) ? $field_settings['op'] : ' AND ';

                switch ($type) {
                    case 'like':
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name like '%:$field_name%'";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                    case 'in':
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name IN (:$field_name)";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                    default:
                        $sql .= ($first !== true ? "$field_connect" : "") . "$field_name = :$field_name";
                        $this->_param_list[] = array(":$field_name", $field_value);
                        break;
                }

                // we can assume that after the first iteration it's false
                $first = false;
            }
        }
        unset($field_connect, $field_name, $field_value, $type, $field_settings);

        if (!empty($this->_group)) {
            if (is_array($this->_group)) {
                $this->_limit = implode(',', $this->_group_by);
            }

            $sql .= ' GROUP BY ' . $this->_group_by;
        }

        if (!empty($this->_limit)) {
            if (is_array($this->_limit)) {
                $this->_limit = implode(',', $this->_limit);
            }

            $sql .= ' LIMIT ' . $this->_limit;
        }

        $this->last_sql = $sql;

        $this->__init_database();

        $stmt = $this->db->prepare($sql);
        // set the prepared statement
        for ($i = 0, $c = count($this->_param_list); $i < $c; $i++) {
            $stmt->bindParam($this->_param_list[$i][0], $this->_param_list[$i][1]);
        }


        if (!$stmt->execute()) return;

        $this->result = $stmt->fetchAll(MySQL::FETCH_OBJ);
    }
988100
public function getAppliedFiles()
    {
        $appliedFinder = $this->getFinder();

        $files = $appliedFinder->files()
            ->in($this->appliedFilesDir)
            ->name(self::PATTERN)
            ->sort($this->sort())
        ;

        return $files;
    }