예제 #1
0
foreach ($tables as $table => $keys) {
    $res = XDB::query("SELECT * FROM geoloc_{$table}");
    if (!$res) {
        echo "{$table}\n";
        continue;
    }
    $all = $res->fetchAllAssoc();
    foreach ($all as &$array) {
        $from = array();
        $to = array();
        foreach ($array as $key => $value) {
            if (in_array($key, $keys)) {
                $from[] = $key . '=' . XDB::escape($value);
            }
            $valued = utf8_decode($value);
            if (is_utf8($value) && $valued != $value) {
                $to[] = $key . '=' . XDB::escape($valued);
            }
        }
        if (!empty($to)) {
            $to = implode(', ', $to);
            $from = implode(' AND ', $from);
            $sql = "UPDATE geoloc_{$table} SET {$to} WHERE {$from}";
            if (!XDB::execute($sql)) {
                echo "Echec : {$sql}\n";
            } elseif (XDB::affectedRows() == 0) {
                echo "{$sql}\n";
            }
        }
    }
}
예제 #2
0
#!/usr/bin/php5
<?php 
require_once 'connect.db.inc.php';
$globals->debug = 0;
//do not store backtraces
$terms = XDB::iterator('SELECT `jtid`, `name` FROM `profile_job_term_enum`');
while ($term = $terms->next()) {
    $tokens = array_unique(JobTerms::tokenize($term['name']));
    if (!count($tokens)) {
        continue;
    }
    $values = array();
    foreach ($tokens as $t) {
        $values[] = '(' . XDB::escape($t) . ',' . XDB::escape($term['jtid']) . ')';
    }
    XDB::execute('INSERT IGNORE INTO `profile_job_term_search` (`search`,`jtid`) VALUES ' . implode(',', $values));
}
/* vim:set et sw=4 sts=4 ts=4: */
예제 #3
0
 public function save(ProfilePage $page, $field, $value)
 {
     XDB::execute("DELETE FROM  profile_mentor_term\n                            WHERE  pid = {?}", $page->pid());
     if (!count($value)) {
         return;
     }
     $mentor_term_values = array();
     foreach ($value as &$term) {
         $mentor_term_values[] = '(' . XDB::escape($page->pid()) . ', ' . XDB::escape($term['jtid']) . ')';
     }
     XDB::execute('INSERT INTO  profile_mentor_term (pid, jtid)
                        VALUES  ' . implode(',', $mentor_term_values));
 }
예제 #4
0
파일: jobterms.php 프로젝트: Ekleog/platal
 /**
  * Create the INNER JOIN query to restrict search to some job terms
  * @param $tokens an array of the job terms to look for (LIKE comp)
  * @param $table_alias the alias or name of the table with a jtid field to restrict
  * @param $table_field the name of the field to restrict in table_alias, usually jtid
  * @return a partial SQL query
  */
 public static function token_join_query(array $tokens, $table_alias, $table_field = 'jtid')
 {
     $joins = '';
     $i = 0;
     foreach ($tokens as $t) {
         ++$i;
         $joins .= ' INNER JOIN  profile_job_term_search AS s' . $i . ' ON(s' . $i . '.jtid = ' . $table_alias . '.' . $table_field . ' AND s' . $i . '.search LIKE ' . XDB::escape($t) . ')';
     }
     return $joins;
 }
예제 #5
0
 public function buildCondition(PlFilter $uf)
 {
     $sub = $uf->addMentorFilter(UserFilter::MENTOR_TERM);
     return $sub . '.jtid_1 = ' . XDB::escape($this->val);
 }