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); } */ }
<?php // include('config.php'); // include('includes.php'); SqlBeginTransaction(); Zoop::loadLib('zend'); $mailConfig = Config::get('app.importer'); $mail = new Zend_Mail_Storage_Pop3(array('host' => $mailConfig['host'], 'user' => $mailConfig['username'], 'password' => $mailConfig['password'], 'ssl' => $mailConfig['ssl'] ? 'SSL' : '')); // $mail = new Zend_Mail_Storage_Imap(array('host' => $mailConfig['host'], // 'user' => $mailConfig['username'], // 'password' => $mailConfig['password'], // 'ssl' => $mailConfig['ssl'] ? 'SSL' : '')); // var_dump($mail); var_dump($count = $mail->countMessages()); foreach ($mail as $message) { // spit out a little info about the message being processed echo "{$message->from}: {$message->to}: {$message->subject}\n"; // see if the from field is like "John Doe <*****@*****.**>" // and if it is parse out the individual fields preg_match('/([\\w ]*)<(\\w.+)@([\\w.]+)>/', $message->from, $matches); if (count($matches) == 4) { $name = trim($matches[1]); $parts = explode(' ', $name); $firstname = array_shift($parts); $lastname = array_pop($parts); $user = trim($matches[2]); $domain = trim($matches[3]); $username = $email = "{$user}@{$domain}"; } else { die("unhandled address format in the 'From' field\n\n"); }
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(); } }