コード例 #1
0
ファイル: Learn.php プロジェクト: laiello/zoop
 public static function regenerateAllWordLetters()
 {
     SqlDeleteRows('delete from word_letter', array());
     $words = SqlFetchRows("select * from word", array());
     SqlEchoOn();
     foreach ($words as $thisWord) {
         Learn::generateWordLetters($thisWord);
     }
 }
コード例 #2
0
 public function getInfo()
 {
     if (!$this->theMany) {
         $remoteTable = DbObject::_getTableName($this->remoteClass);
         $sql = "select * from {$remoteTable} \n\t\t\t\t\tinner join {$this->joinTable} on {$this->joinTable}.{$this->joinTableRemoteField} = {$remoteTable}.{$this->remoteField}\n\t\t\t\t\twhere {$this->joinTable}.{$this->joinTableLocalField} = :id:int";
         $rows = SqlFetchRows($sql, array('id' => $this->dbObject->getScalar($this->localField)));
         $this->theMany = array();
         foreach ($rows as $thisRow) {
             $this->theMany[] = new $className($thisRow);
         }
     }
     return $this->theMany;
 }
コード例 #3
0
ファイル: ZoneDefault.php プロジェクト: laiello/zoop
 function pageGetSuggestions($p, $z)
 {
     $start = microtime(1);
     $tray = $p[1];
     if (isset($p[2]) && $p[2]) {
         $testList = array($p[2]);
     } else {
         $testList = array('W', 'A', 'R', 'T', 'E', 'D');
     }
     foreach ($testList as $test) {
         echo "<br><br><strong>test = {$test}</strong><br>";
         $sql = "select\n\t\t\t\t\t\tword.word\n\t\t\t\t\tfrom\n\t\t\t\t\t\tword\n\t\t\t\t\t\tinner join word_letter on word.id = word_letter.word_id\n\t\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\t\tword.id, word.word, word.len\n\t\t\t\t\thaving\n\t\t\t\t\t\t(sum(word_letter.count) = word.len) \n\t\t\t\t\t\tand\n\t\t\t\t\t\t{$testList}\n\t\t\t\t\t";
         // echo_r($sql);
         $rows = SqlFetchRows($sql, array());
         foreach ($rows as $thisRow) {
             echo $thisRow['word'] . '<br>';
         }
     }
     $end = microtime(1);
     echo '<br> time = ' . ($end - $start);
 }
コード例 #4
0
ファイル: index.php プロジェクト: laiello/zoop
<?php

include 'config.php';
include zoop_dir . '/Zoop.php';
Zoop::loadLib('db');
$map = SqlFetchSimpleMap('select * from test', 'name', 'value', array());
echo_r($map);
$rows = SqlFetchRows('select * from test', array());
echo_r($rows);
$rows = SqlFetchRows('select * from test where name = :name', array('name' => 'one'));
echo_r($rows);
コード例 #5
0
ファイル: index.php プロジェクト: rgigger/zinc
<?php

// include('config.php');
define('app_dir', __DIR__);
include dirname(dirname(__DIR__)) . '/framework/Zinc.php';
Zinc::loadLib('app');
Zinc::loadLib('db');
$map = SqlFetchSimpleMap('select * from test', 'one', 'two', array());
echo_r($map);
$rows = SqlFetchRows('select * from test', array());
echo_r($rows);
コード例 #6
0
ファイル: index.php プロジェクト: laiello/zoop
<?php

include 'config.php';
include zoop_dir . '/Zoop.php';
Zoop::loadLib('db');
$map = SqlFetchSimpleMap('select * from test', 'name', 'value', array());
echo_r($map);
$rows = SqlFetchRows('select * from test', array());
echo_r($rows);
$rows = SqlFetchRows('select * from test where id = :id', array('id' => 2));
echo_r($rows);
$rows = SqlFetchRows('select id::int from test', array());
echo_r($rows);
コード例 #7
0
ファイル: Board.php プロジェクト: laiello/zoop
 public function loadCells()
 {
     $rows = SqlFetchRows("select * from board_cell where board_id = :boardId", array('boardId' => $this->id));
     foreach ($rows as $thisRow) {
         $this->setCellLetter($thisRow['row_num'], $thisRow['col_num'], $thisRow['letter']);
     }
 }