このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン 両方とも次のリビジョン | ||
apricot:core:top [2020/05/01 22:33] y2sunlight [Apricot コア作成の準備] |
apricot:core:top [2020/05/09 16:45] y2sunlight [Apricot コア作成の準備] |
||
---|---|---|---|
行 9: | 行 9: | ||
* Apricot コア | * Apricot コア | ||
* Apricot コア作成の準備 | * Apricot コア作成の準備 | ||
- | * [[apricot: | + | * [[apricot: |
* [[apricot: | * [[apricot: | ||
* [[apricot: | * [[apricot: | ||
* [[apricot: | * [[apricot: | ||
+ | * [[apricot: | ||
+ | * [[apricot: | ||
* [[apricot: | * [[apricot: | ||
* [[apricot: | * [[apricot: | ||
- | |||
- | \\ | ||
まずは、apricotのコアを作る為に以下を準備します。 | まずは、apricotのコアを作る為に以下を準備します。 | ||
行 23: | 行 23: | ||
* コアフォルダ、名前空間、オートローディングの設定 | * コアフォルダ、名前空間、オートローディングの設定 | ||
* コア構築のヘルパーとなるグローバル関数とベースクラス | * コア構築のヘルパーとなるグローバル関数とベースクラス | ||
+ | |||
---- | ---- | ||
行 390: | 行 391: | ||
{ | { | ||
return (new \ReflectionClass($object))-> | return (new \ReflectionClass($object))-> | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Get SQL text from a file | ||
+ | * @param string $filename | ||
+ | * @return array | ||
+ | */ | ||
+ | function file_get_sql(string $filename): | ||
+ | { | ||
+ | if (!file_exists($filename)) return []; | ||
+ | |||
+ | // Read a file | ||
+ | $text = file_get_contents($filename); | ||
+ | $text = str_replace([" | ||
+ | |||
+ | // Remove comment | ||
+ | $text = preg_replace("/ | ||
+ | $text = preg_replace("/ | ||
+ | |||
+ | // Split SQL text | ||
+ | $sql = preg_split("/ | ||
+ | array_walk($sql, | ||
+ | $item = trim($item); | ||
+ | }); | ||
+ | $sql = array_filter($sql, | ||
+ | return !empty(trim($val)); | ||
+ | }); | ||
+ | return $sql; | ||
} | } | ||
</ | </ |