public function database() { if (file_exists(Compose::databasePath())) { self::$database = true; } else { die(Compose::databasePath() . ' does not exist'); } }
public static function update($column, $value) { if (Compose::prepared()) { $rows = Compose::databaseTableRows(); if (array_key_exists(Compose::table(), Compose::where())) { // change this, it's a bug new Compile(Compose::where()); $where = Compose::where(); foreach ($where[Compose::table()] as $key => $values) { $where[Compose::table()][$key][$column] = $value; } new Compile($where); $rows[Compose::table()] = array_replace($rows[Compose::table()], $where[Compose::table()]); $encodeRows = database::encodeDatabaseTableRows(Compose::table(), $rows); $seperateEncodedRows = implode("\n", $encodeRows); new Compile($seperateEncodedRows); new Compile($encodeRows); $addRowTable = "|" . Compose::table() . "{\n\n" . Compose::databaseCode()["inTableColumns"][Compose::table()] . "\n\n" . $seperateEncodedRows . "\n\n}." . Compose::table() . ";"; $content = preg_replace(sprintf(Initialize::$replace["table"], Compose::table(), Compose::table()), $addRowTable, Compose::databaseFile3()); new Compile($content); file_put_contents(Compose::databasePath(), $content); new Compile($rows); } else { // not using where, updating all rows foreach ($rows[Compose::table()] as $key => $values) { $rows[Compose::table()][$key][$column] = $value; } new Compile($rows); $encodeRows = database::encodeDatabaseTableRows(Compose::table(), $rows); $seperateEncodedRows = implode("\n", $encodeRows); new Compile($seperateEncodedRows); new Compile($encodeRows); $addRowTable = "|" . Compose::table() . "{\n\n" . Compose::databaseCode()["inTableColumns"][Compose::table()] . "\n\n" . $seperateEncodedRows . "\n\n}." . Compose::table() . ";"; $content = preg_replace(sprintf(Initialize::$replace["table"], Compose::table(), Compose::table()), $addRowTable, Compose::databaseFile3()); new Compile($content); file_put_contents(Compose::databasePath(), $content); } } else { die("Prepare method not called"); } }
public static function databaseFile2() { return str_replace(PHP_EOL, "", file_get_contents(Compose::databasePath())); }