static function getAllAppiedMigrationNames($type) { if ($type != 'migration' && $type != 'seed') { trigger_error("invalid migration type: {$type}"); } return SqlFetchColumn("select name from {$type} where applied = 1", array()); }
function getMatches($tray, $test) { $test = strtoupper($test); $sql = "select\n\t\t\t\t\tword.word\n\t\t\t\tfrom\n\t\t\t\t\tword\n\t\t\t\t\tinner join word_letter on word.id = word_letter.word_id\n\t\t\t\twhere"; $all = $tray . $test; $len = strlen($all); $counts = array(); for ($i = 0; $i < $len; $i++) { if (isset($counts[$all[$i]])) { $counts[$all[$i]]++; } else { $counts[$all[$i]] = 2; } } $parts = array(); for ($i = 0; $i < $len; $i++) { $parts[] = "(word_letter.letter = '" . $all[$i] . "' and word_letter.count < " . $counts[$all[$i]] . ")\n"; } $sql .= implode(' or ', $parts); $len = strlen($test); $parts = array(); for ($i = 0; $i < $len; $i++) { $parts[] = "(sum(case when word_letter.letter = '" . $test[$i] . "' then word_letter.count else 0 end) > 0)\n"; } $testList = implode(' and ', $parts); $sql .= "group by\n\t\t\t\t\tword.id, \n\t\t\t\t\tword.word, \n\t\t\t\t\tword.len\n\t\t\t\thaving\n\t\t\t\t\t(sum(word_letter.count) = word.len) \n\t\t\t\t\tand\n\t\t\t\t\t{$testList}\n\t\t\t\t"; // echo_r($sql); $words = SqlFetchColumn($sql, array()); return $words; }
function getAllAppiedMigrationNames() { return SqlFetchColumn("select name from migration where applied = 1", array()); }