function subMigration($p, $s) { $version = $p[3]; SqlBeginTransaction(); $filename = Migration::filenameFromVersion($version); Migration::apply($filename, $version); SqlCommitTransaction(); }
public function handleRedo($p) { $version = $p[3]; SqlBeginTransaction(); $filename = Migration::filenameFromVersion($version, 'migration'); Migration::undo($filename, $version, 'migration'); Migration::apply($filename, $version, 'migration'); SqlCommitTransaction(); die; }
function subMigrations($p, $s) { SqlBeginTransaction(); // make sure the migrations table exists Migration::initDB(); // have it scan the migrations directory for all available migrations $versions = Migration::getAllMigrationNames(); // print_r($versions); $flipped = array_flip($versions); // query the db for applied migrations in reverse order $applied = Migration::getAllAppiedMigrationNames(); // print_r($applied); print_r($versions); print_r($applied); // undo all of the migrations foreach ($applied as $key => $migration) { Migration::undo($flipped[$migration], $migration); } // now, reapply all of them foreach ($versions as $key => $migration) { Migration::apply($key, $migration); } SqlCommitTransaction(); // apply anything that hasn't been done yet, in the proper order // $unapplied = array_diff($versions, $applied); // print_r($unapplied);die(); // foreach($unapplied as $key => $needsApplied) // { // Migration::apply($key, $needsApplied); // } /* // make sure the migrations table exists $schema = SqlGetSchema(); if(!$schema->tableExists('migrations')) { SqlAlterSchema("create table migrations ( id serial primary key, name text not null, applied int2 not null default 0)"); } // have it scan the migrations directory for all available migrations $filenames = ListDir(getcwd() . '/migrations', array('extentions' => array('php'))); $versions = array(); foreach($filenames as $thisFilename) { $parts = explode('_', $thisFilename); $version = $parts[0]; $versions[$thisFilename] = $version; } // query the db for applied migrations $applied = SqlFetchColumn("select name from migrations where applied = 1", array()); // apply anything that hasn't been done yet, in the proper order $unapplied = array_diff($versions, $applied); print_r($unapplied); foreach($unapplied as $key => $needsApplied) { // apply the migration include_once(getcwd() . '/migrations/' . $key); $className = 'Migration_' . str_replace('.', '_', $needsApplied); $migration = new $className(); $migration->up(); // mark it as applied SqlUpsertRow('migrations', array('name' => $needsApplied), array('applied' => 1)); print_r($migration); } */ }
} } function importFile($part) { $res = preg_match('/(.*); name="(.*)"/', $part->contentType, $matches); $type = $matches[1]; $name = $matches[2]; if ($part->contentTransferEncoding == 'base64') { $content = base64_decode($part->getContent()); $hash = md5($content); $path = Config::get('app.var'); if (!$path) { trigger_error("no Config value set for app.var"); } $path .= '/attachments'; $path .= '/' . $hash; file_put_contents($path, $content); $attachment = new Attachment(); $attachment->name = $name; $attachment->type = $type; $attachment->hash = $hash; $contentId = $part->headerExists('content-id') ? substr($part->contentId, 1, strlen($part->contentId) - 2) : null; $info = array('name' => $name, 'type' => $type, 'hash' => $hash, 'contentId' => $contentId); // print_r($info); return $info; } else { trigger_error("attachment encoding {$part->contentTransferEncoding} not handled"); } } SqlCommitTransaction();
public function getWords() { $words = array(); for ($row = 1; $row <= self::size; $row++) { $word = ''; for ($col = 1; $col <= self::size; $col++) { $letter = $this->cells[$row][$col]->getLetter(); if ($letter) { $word .= $letter; } else { if ($word) { $words[$word] = 1; $word = ''; } } } if ($word) { $words[$word] = 1; $word = ''; } } for ($col = 1; $col <= self::size; $col++) { $word = ''; for ($row = 1; $row <= self::size; $row++) { $letter = $this->cells[$row][$col]->getLetter(); if ($letter) { $word .= $letter; } else { if ($word) { $words[$word] = 1; $word = ''; } } } if ($word) { $words[$word] = 1; $word = ''; } } // SqlEchoOn(); foreach ($words as $thisWord => $thing) { SqlBeginTransaction(); $word = strtoupper($thisWord); $len = strlen($word); if ($len < 2) { continue; } $id = SqlFetchCell("select id from word where word = :word", array('word' => $word)); if (!$id) { echo "inserting word: {$word}<br>"; SqlInsertRow("insert into word (word, len) values (:wordwrap, :len)", array('word' => $word, 'len' => $len)); Learn::generateWordLetters($word); } SqlCommitTransaction(); } }