本文整理汇总了PHP中safe_w_affected_rows函数的典型用法代码示例。如果您正苦于以下问题:PHP safe_w_affected_rows函数的具体用法?PHP safe_w_affected_rows怎么用?PHP safe_w_affected_rows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_w_affected_rows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SetElimArrowValue
function SetElimArrowValue($Phase, $Event, $Target, $ArIndex, $ArSymbol, $Output = 'XML', $CompId = '')
{
require_once 'Common/Lib/Obj_RankFactory.php';
$JsonResult = array();
$JsonResult['error'] = 1;
$JsonResult['qutarget'] = $_REQUEST['qutarget'];
$JsonResult['distnum'] = $_REQUEST['distnum'];
$JsonResult['arrowindex'] = $_REQUEST['arrowindex'];
$JsonResult['arrowsymbol'] = '';
$JsonResult['curscore'] = '';
$JsonResult['curgold'] = '';
$JsonResult['curxnine'] = '';
$JsonResult['score'] = '';
$JsonResult['gold'] = '';
$JsonResult['xnine'] = '';
if (empty($CompId)) {
$CompId = $_SESSION['TourId'];
}
$q = safe_r_sql("select * from Eliminations\r\n\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\tand ElEventCode='{$Event}'\r\n\t\tand ElTargetNo='{$Target}'\r\n\t\tand ElTournament={$CompId}\r\n\t\t");
if ($r = safe_fetch($q)) {
$Arrowstring = str_pad($r->ElArrowString, $ArIndex + 1, ' ', STR_PAD_RIGHT);
$xx = GetLetterFromPrint($ArSymbol);
$Arrowstring[$ArIndex] = str_pad($xx, 1, ' ', STR_PAD_RIGHT);
list($CurScore, $CurGold, $CurXNine) = ValutaArrowStringGX($Arrowstring);
safe_w_sql("update Eliminations\r\n\t\t\tset ElArrowString='{$Arrowstring}',\r\n\t\t\tElScore={$CurScore},\r\n\t\t\tElGold={$CurGold},\r\n\t\t\tElXnine={$CurXNine}\r\n\t\t\twhere ElElimPhase=" . ($Phase[1] - 1) . "\r\n\t\t\tand ElEventCode='{$Event}'\r\n\t\t\tand ElTargetNo='{$Target}'\r\n\t\t\tand ElTournament={$CompId}");
if (safe_w_affected_rows()) {
if ($Phase[1] == 1) {
require_once 'Common/Fun_Sessions.inc.php';
ResetElimRows($Event, 2);
}
Obj_RankFactory::create('ElimInd', array('tournament' => $CompId, 'eventsC' => array($Event . '@' . $Phase[1])))->calculate();
}
$JsonResult['error'] = 0;
$JsonResult['arrowsymbol'] = $xx ? strtoupper($ArSymbol) : '';
$JsonResult['curscore'] = $CurScore;
$JsonResult['curgold'] = $CurGold;
$JsonResult['curxnine'] = $CurXNine;
$JsonResult['score'] = $CurScore;
$JsonResult['gold'] = $CurGold;
$JsonResult['xnine'] = $CurXNine;
}
return $JsonResult;
}
示例2: SetAccreditation
function SetAccreditation($Id, $SetRap = 0, $return = 'RicaricaOpener', $TourId = 0, $AccOp = 0)
{
$RicaricaOpener = false;
if (!$TourId) {
$TourId = $_SESSION['TourId'];
}
if (!$AccOp) {
$AccOp = $_SESSION['AccOp'];
}
/*
* Devo prevenire l'insert se l'id è in stato 7.
* Per farlo cerco lo stato del tizio.
* Se è 7 vuol dire che uno ha cliccato sul bottone dopo aver aperto il popup e io non scrivo in db
*/
$Select = "SELECT EnId FROM Entries\n\t\tWHERE EnId=" . StrSafe_DB($Id) . " AND EnTournament={$TourId} AND EnStatus='7' ";
$Rs = safe_r_sql($Select);
//TODO Patchare la query per supportare bene IpV6
if (safe_num_rows($Rs) == 0) {
$Insert = "INSERT INTO AccEntries\n\t\t\t(AEId,AEOperation,AETournament,AEWhen,AEFromIp,AERapp)\n\t\t\tVALUES(\n\t\t\t\t{$Id}," . StrSafe_DB($AccOp) . "," . StrSafe_DB($TourId) . "," . StrSafe_DB(date('Y-m-d H:i')) . "," . "INET_ATON('" . ($_SERVER['REMOTE_ADDR'] != '::1' ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1') . "'), " . StrSafe_DB($SetRap) . "" . ") ON DUPLICATE KEY UPDATE " . "AEWhen=" . StrSafe_DB(date('Y-m-d H:i')) . "," . "AEFromIp=INET_ATON('" . ($_SERVER['REMOTE_ADDR'] != '::1' ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1') . "') ";
$RsIns = safe_w_sql($Insert);
$RicaricaOpener = $return == 'RicaricaOpener' ? true : (safe_w_affected_rows() ? 'AccreditationOK' : 'AccreditationTwice');
}
return $RicaricaOpener;
}
示例3: nextPhase
//.........这里部分代码省略.........
$error = true;
return;
}
foreach ($keys as $key => $value) {
$events = implode(',', array_keys($value));
$query = "";
if ($team == 0) {
$query = "SELECT GrPhase AS Phase,GrPosition AS Position,\t/* Grids*/ " . "FinMatchNo AS MatchNo,FinEvent AS Event, FinAthlete AS Id, FinScore AS Score,FinTie AS Tie, " . "IF(GrPhase>2, FLOOR(FinMatchNo/2),FLOOR(FinMatchNo/2)-2) AS NextMatchNo " . "FROM Finals INNER JOIN Grids ON FinMatchNo=GrMatchNo AND GrPhase=" . StrSafe_DB($key) . " " . "LEFT JOIN Entries ON FinAthlete=EnId AND FinEvent IN(" . $events . ') ' . "WHERE FinTournament=" . $this->getTourId() . " " . "ORDER BY FinEvent, NextMatchNo ASC, FinScore DESC, FinTie DESC ";
} else {
$query = "SELECT GrPhase AS Phase,GrPosition AS Position,\t/* Grids*/ " . "TfTeam AS Id,TfMatchNo AS MatchNo,TfEvent AS Event, TfScore AS Score,TfTie AS Tie, " . "IF(GrPhase>2, FLOOR(TfMatchNo/2),FLOOR(TfMatchNo/2)-2) AS NextMatchNo " . "FROM TeamFinals INNER JOIN Grids ON TfMatchNo=GrMatchNo AND GrPhase=" . StrSafe_DB($key) . " " . "WHERE TfTournament=" . $this->getTourId() . " AND TfEvent IN (" . $events . ") " . "ORDER BY TfEvent, NextMatchNo ASC, TfScore DESC, TfTie DESC ";
}
//print $query . '<br>';exit;
$rs = safe_r_SQL($query);
$myNextMatchNo = 'xx';
$row = array();
if (safe_num_rows($rs) > 0) {
while ($row0 = safe_fetch($rs)) {
$row1 = safe_fetch($rs);
$athProp = 0;
$myUpQuery = "";
if ($row0->Phase >= 2) {
if (($row0->Score > 0 || $row0->Tie > 0) && ($row0->Score != $row1->Score || $row0->Tie != $row1->Tie)) {
if ($team == 0) {
$myUpQuery = "UPDATE Finals SET ";
$myUpQuery .= "FinAthlete =" . StrSafe_DB($row0->Id) . ", ";
$myUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$myUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row0->Event) . " AND FinMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND FinTournament=" . $this->getTourId() . " ";
} else {
$myUpQuery = "UPDATE TeamFinals SET ";
$myUpQuery .= "TfTeam =" . StrSafe_DB($row0->Id) . ", ";
$myUpQuery .= "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$myUpQuery .= "WHERE TfEvent=" . StrSafe_DB($row0->Event) . " AND TfMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND TfTournament=" . $this->getTourId() . " ";
}
//print $myUpQuery . '<br><br>';
$rsUp = safe_w_sql($myUpQuery);
$athProp = $row0->Id;
} else {
if ($team == 0) {
$myUpQuery = "UPDATE Finals SET ";
$myUpQuery .= "FinAthlete ='0', ";
$myUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$myUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row0->Event) . " AND FinMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND FinTournament=" . $this->getTourId() . " ";
} else {
$myUpQuery = "UPDATE TeamFinals SET ";
$myUpQuery .= "TfTeam ='0', ";
$myUpQuery .= "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$myUpQuery .= "WHERE TfEvent=" . StrSafe_DB($row0->Event) . " AND TfMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND TfTournament=" . $this->getTourId() . " ";
}
$rsUp = safe_w_sql($myUpQuery);
}
}
if ($row1->Phase == 2) {
if (($row1->Score > 0 || $row1->Tie > 0) && ($row0->Score != $row1->Score || $row0->Tie != $row1->Tie)) {
if ($team == 0) {
$myUpQuery = "UPDATE Finals SET ";
$myUpQuery .= "FinAthlete =" . StrSafe_DB($row1->Id) . ", ";
$myUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$myUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row1->Event) . " AND FinMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND FinTournament=" . $this->getTourId() . " ";
} else {
$myUpQuery = "UPDATE TeamFinals SET ";
$myUpQuery .= "TfTeam =" . StrSafe_DB($row1->Id) . ", ";
$myUpQuery .= "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$myUpQuery .= "WHERE TfEvent=" . StrSafe_DB($row1->Event) . " AND TfMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND TfTournament=" . $this->getTourId() . " ";
}
$rsUp = safe_w_sql($myUpQuery);
$athProp = $Row1->FinAthlete;
} else {
if ($team == 0) {
$myUpQuery = "UPDATE Finals SET ";
$myUpQuery .= "FinAthlete =" . StrSafe_DB($row1->Id) . ", ";
// 0
$myUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$myUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row1->Event) . " AND FinMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND FinTournament=" . $this->getTourId() . " ";
} else {
$myUpQuery = "UPDATE TeamFinals SET ";
$myUpQuery .= "TfTeam =" . StrSafe_DB($row1->Id) . ", ";
// 0
$myUpQuery .= "TfDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$myUpQuery .= "WHERE TfEvent=" . StrSafe_DB($row1->Event) . " AND TfMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND TfTournament=" . $this->getTourId() . " ";
}
$rsUp = safe_w_sql($myUpQuery);
}
// Devo fare la propagazione del nome se il matchno>7 (fase>2)
$oldId = $athProp != 0 ? StrSafe_DB($row1->Id) : StrSafe_DB($row0->Id) . ',' . StrSafe_DB($row1->Id);
$update = "";
if ($team == 0) {
$update = "UPDATE Finals SET " . "FinAthlete=" . StrSafe_DB($athProp) . " " . "WHERE FinAthlete IN (" . $oldId . ") AND FinTournament=" . $this->getTourId() . " AND FinEvent=" . StrSafe_DB($row0->Event) . " AND FinMatchNo<" . StrSafe_DB($row0->NextMatchNo) . " AND (FinScore<>0 OR FinTie<>0) ";
} else {
$update = "UPDATE TeamFinals SET " . "TfTeam=" . StrSafe_DB($athProp) . " " . "WHERE TfTeam IN (" . $oldId . ") AND TfTournament=" . $this->getTourId() . " AND TfEvent=" . StrSafe_DB($row0->Event) . " AND TfMatchNo<" . StrSafe_DB($row0->NextMatchNo) . " AND (TfScore<>0 OR TfTie<>0) ";
}
//print $update . '<br><br>';
$rsProp = safe_w_sql($update);
if (safe_w_affected_rows() > 0) {
$error = false;
}
}
}
}
}
}
示例4: StrSafe_DB
* purchè il flag di partecipazione alle finali ind sia a 1.
* Se una persona rispetta il filtro ma non partecipa alle finali ind, il bersaglio NON
* viene toccato
*/
$query = "UPDATE " . "Entries " . "INNER JOIN " . "Qualifications " . "ON EnId=QuId AND EnIndFEvent=1 " . "INNER JOIN " . "EventClass " . "ON EnDivision=EcDivision AND EnClass=EcClass AND EnTournament=EcTournament AND EcTeamEvent=0 " . "SET " . "Qualifications.QuTargetNo='', QuBacknoPrinted=0 ";
if ($delSession == 1) {
$query .= ",Qualifications.QuSession=0 ";
}
$query .= "WHERE " . "Entries.EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " " . "AND EcCode LIKE " . StrSafe_DB($filter) . " ";
if ($session != 0) {
$query .= " AND Qualifications.QuSession=" . StrSafe_DB($session) . " ";
}
}
$rs = safe_w_SQL($query);
if ($rs) {
if (safe_w_affected_rows() > 0) {
$msg = get_text('TargetDeleted');
} else {
$msg = get_text('NoTargetFound');
}
} else {
$msg = get_text('Error');
}
} else {
$msg = get_text('Error');
}
} else {
$msg = get_text('Error');
}
}
$JS_SCRIPT = array(phpVars2js(array('StrAreYouSure' => get_text('MsgAreYouSure'))), '<script type="text/javascript" src="' . $CFG->ROOT_DIR . 'Partecipants/Fun_DeleteTarget.js"></script>');
示例5: MakeIndividuals
/**
* MakeIndividuals()
* Aggiunge o toglie le righe ad Individuals.
*
* @param string[] $affected: contiene gli eventi assoluti che hanno subito una modifica (aggiunte o cancellazioni)
* @param int $tournament: contiene il torneo su cui lavorare. se null prende dalla sessione
* @return bool: true in caso di errore, false altrimenti
*/
function MakeIndividuals(&$affected, $tournament = null)
{
if (is_null($tournament)) {
$tournament = $_SESSION['TourId'];
}
// get the QT nations
//Se esiste il quota tournament cancello i "non elegible"
$dbValues = array();
$QTNations = array();
$QTDates = array();
if (module_exists('QuotaTournament')) {
$tmp = getModuleParameter("QuotaTournament", "allowedIOC", '');
if (strlen($tmp) > 0) {
$dbValues = unserialize($tmp);
foreach ($dbValues as $k => $v) {
if (substr($k, 0, 3) == 'ev_') {
$evCode = explode("_", $k);
$evCode = $evCode[2];
$QTNations[$evCode] = $v;
}
}
}
}
//Mi prendo gli eventi a cui agigungerò qualcuno
$q = "\r\n\t\tSELECT DISTINCT\r\n\t\t\tEcCode, CoCode\r\n\t\tFROM\r\n\t\t\tEntries\r\n\t\tINNER JOIN\r\n\t\t\tEventClass ON EnTournament=EcTournament AND EcTeamEvent=0 AND EnDivision=EcDivision AND EnClass=EcClass\r\n\t\tINNER JOIN\r\n\t\t\tCountries ON CoId=EnCountry\r\n\t\tLEFT JOIN\r\n\t\t\tIndividuals ON IndId=EnId AND IndTournament=EnTournament AND IndEvent=EcCode\r\n\t\tWHERE EnTournament = {$tournament} AND IndEvent IS NULL AND EnIndFEvent=1 AND EnStatus<=1";
$r = safe_r_sql($q);
//print $q;exit;
if (safe_num_rows($r) > 0) {
while ($myRow = safe_fetch($r)) {
if (!in_array($myRow->EcCode, $affected, true) and !(!empty($QTNations[$myRow->EcCode]) and !in_array($myRow->CoCode, $QTNations[$myRow->EcCode]))) {
$affected[] = $myRow->EcCode;
}
}
//Siccome il nume_rows era >0, aggiungo chi mi manca
$q = "\r\n\t\t\tINSERT INTO\r\n\t\t\t\tIndividuals (IndId,IndEvent,IndTournament,IndTimestamp)\r\n\t\t\tSELECT\r\n\t\t\t\tEnId, EcCode, EnTournament, NOW()\r\n\t\t\tFROM\r\n\t\t\t\tEntries\r\n\t\t\tINNER JOIN\r\n\t\t\t\tEventClass ON EnTournament=EcTournament AND EcTeamEvent=0 AND EnDivision=EcDivision AND EnClass=EcClass\r\n\t\t\tLEFT JOIN\r\n\t\t\t\tIndividuals ON IndId=EnId AND IndTournament=EnTournament AND IndEvent=EcCode\r\n\t\t\tWHERE EnTournament = {$tournament} AND IndEvent IS NULL AND EnIndFEvent=1 AND EnStatus<=1";
$r = safe_w_sql($q);
}
//Mi prendo gli eventi da cancellare
$q = "\r\n\t\tSELECT DISTINCT\r\n\t\t\tIndEvent\r\n\t\tFROM\r\n\t\t\tIndividuals\r\n\t\tLEFT JOIN\r\n\t\t\t(SELECT\r\n\t\t\t\tEnId, EcCode\r\n\t\t\tFROM\r\n\t\t\t\tEntries\r\n\t\t\tINNER JOIN\r\n\t\t\t\tEventClass ON EnTournament = EcTournament AND EcTeamEvent =0 AND EnDivision = EcDivision AND EnClass = EcClass\r\n\t\t\tWHERE\r\n\t\t\t\tEnTournament = {$tournament} AND EnIndFEvent=1 AND EnStatus<=1\r\n\t\t\t) AS sq ON IndId = EnId AND IndEvent = EcCode\r\n\t\tWHERE\r\n\t\t\tIndTournament = {$tournament} AND EnId IS NULL";
$r = safe_r_sql($q);
if (safe_num_rows($r) > 0) {
while ($myRow = safe_fetch($r)) {
if (!in_array($myRow->IndEvent, $affected, true)) {
$affected[] = $myRow->IndEvent;
}
}
//Siccome il nume_rows era >0, tolgo chi cresce
$q = "\r\n\t\t\tDELETE Individuals FROM\r\n\t\t\t\tIndividuals\r\n\t\t\tLEFT JOIN\r\n\t\t\t\t(SELECT\r\n\t\t\t\t\tEnId, EcCode\r\n\t\t\t\tFROM\r\n\t\t\t\t\tEntries\r\n\t\t\t\tINNER JOIN\r\n\t\t\t\t\tEventClass ON EnTournament = EcTournament AND EcTeamEvent =0 AND EnDivision = EcDivision AND EnClass = EcClass\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tEnTournament = {$tournament} AND EnIndFEvent=1 AND EnStatus<=1\r\n\t\t\t\t) AS sq ON IndId = EnId AND IndEvent = EcCode\r\n\t\t\tWHERE\r\n\t\t\t\tIndTournament = {$tournament} AND EnId IS NULL";
$r = safe_w_sql($q);
}
//Se esiste il quota tournament cancello i "non elegible"
if (module_exists('QuotaTournament')) {
$dbValues = array();
$tmp = getModuleParameter("QuotaTournament", "allowedIOC", '');
if (strlen($tmp) > 0) {
$dbValues = unserialize($tmp);
foreach ($dbValues as $k => $v) {
if (substr($k, 0, 3) == 'ev_') {
$evCode = explode("_", $k);
$evCode = $evCode[2];
$q = "DELETE FROM Individuals\r\n\t\t\t\t\t\tUSING Individuals\r\n\t\t\t\t\t\tINNER JOIN Entries ON IndId = EnId AND IndTournament=EnTournament\r\n\t\t\t\t\t\tINNER JOIN Countries ON EnCountry=CoId AND EnTournament=CoTournament\r\n\t\t\t\t\t\tINNER JOIN EventClass ON EnTournament = EcTournament AND EcTeamEvent =0 AND\r\n\t\t\t\t\t\tEnDivision = EcDivision AND EnClass = EcClass AND IndEvent = EcCode\r\n\t\t\t\t\t\tWHERE EnTournament = {$tournament} AND EnIndFEvent=1 AND EnStatus<=1 AND EcCode='{$evCode}'\r\n\t\t\t\t\t\tAND CoCode NOT IN ('" . implode("', '", $v) . "')";
$r = safe_w_sql($q);
if (safe_w_affected_rows()) {
if (!in_array($k, $affected, true)) {
$affected[] = $k;
}
}
} else {
if (substr($k, 0, 4) == 'dob_') {
$evCode = explode("_", $k);
$dobType = $evCode[1];
$evCode = $evCode[2];
$q = "DELETE FROM Individuals\r\n\t\t\t\t\t\tUSING Individuals\r\n\t\t\t\t\t\tINNER JOIN Entries ON IndId = EnId AND IndTournament=EnTournament\r\n\t\t\t\t\t\tINNER JOIN Countries ON EnCountry=CoId AND EnTournament=CoTournament\r\n\t\t\t\t\t\tINNER JOIN EventClass ON EnTournament = EcTournament AND EcTeamEvent =0 AND\r\n\t\t\t\t\t\tEnDivision = EcDivision AND EnClass = EcClass AND IndEvent = EcCode\r\n\t\t\t\t\t\tWHERE EnTournament = {$tournament} AND EnIndFEvent=1 AND EnStatus<=1 AND EcCode='{$evCode}'\r\n\t\t\t\t\t\tAND EnDob " . ($dobType == 's' ? "<=" : ">=") . " '{$v}'";
$r = safe_w_sql($q);
if (safe_w_affected_rows()) {
if (!in_array($k, $affected, true)) {
$affected[] = $k;
}
}
}
}
}
}
}
return false;
}
示例6: setRow
/**
* setRow().
* Imposta le ElRank degli elementi passati.
*
* Questo è il metodo da chiamare quando si risolvono gli spareggi perchè chi non passa ha la rank a posto
* grazie a calculate() e gli altri (sia quelli a cavallo che i buoni di sicuro) vanno impostati a mano.
*
*
* @param mixed $items: array degli elementi da scrivere.
* La struttra è la seguente:
* array(
* array(
* ath => <id> (chiave)
* event => <ev> (chiave)
* phase => <phase> (chiave)
* rank => <rank>
* so => <so>
* )
* )
* con <id> l'id della persona <ev> l'evento, <phase> il girone eliminatorio (0 vuol dire primo girone, 1 il secondo),
* <rank> la rank da impostare (opzionale), e <so> un flag che vale 1 se ci sono spareggi (gialli o rossi, opzionale).
*
* Deve essere presente almeno un campo opzionale se no il metodo ritorna errore.
*
* NOTA BENE
* Qui phase ha i valori del db quindi 0->I girone, 1->II girone!!!!
*
* @return mixed: ritorna le affected_rows oppure false se c'è qualche errore
* (non salva gli eventuali elementi successivi a quello che ha generato l'errore)
*/
public function setRow($items = array())
{
// campi mandatory per $item
$params = array('ath', 'event', 'phase');
$affected = 0;
foreach ($items as $item) {
/*print '<pre>';
print_r($item);
print '</pre>';*/
$paramsOk = true;
$canUp = false;
/*
* controllo che ci siano i campi mandatory
*/
foreach ($params as $p) {
if (!array_key_exists($p, $item)) {
$paramsOk = false;
$ret = false;
break;
}
}
if (!$paramsOk) {
continue;
}
$date = date('Y-m-d H:i:s');
$q = "UPDATE " . "Eliminations " . "SET " . "ElDateTime='{$date}' ";
/* campi opzionali e basta */
if (array_key_exists('rank', $item)) {
$canUp = true;
$q .= ",ElRank={$item['rank']}";
}
if (array_key_exists('so', $item)) {
$canUp = true;
$q .= ",ElSO={$item['so']}";
}
if (array_key_exists('tiebreak', $item)) {
$canUp = true;
$q .= ",ElTiebreak='{$item['tiebreak']}' ";
}
$phase = $item['phase'];
$q .= " WHERE " . "ElId=" . $item['ath'] . " AND ElTournament=" . $this->tournament . " AND ElElimPhase={$phase} AND ElEventCode='{$item['event']}'";
//print $q.'<br><br>';
if (!$canUp) {
return false;
}
$r = safe_w_sql($q);
if (!$r) {
$affected = false;
} else {
$affected += safe_w_affected_rows();
}
}
return $affected;
}
示例7: foreach
// campo 2 da usare come chiave per l'update
foreach ($_REQUEST as $Key => $Value) {
$Field = '';
$Id = '';
$ClDivAllowed = '';
if (substr($Key, 0, 2) == 'd_') {
$tmp = explode('_', $Key);
$Field = $tmp[1];
$Id = $tmp[2];
if (!empty($tmp[3])) {
$ClDivAllowed = $tmp[3];
}
$Which = $Key;
$Update = "UPDATE " . $tt . " SET " . $Field . "=" . StrSafe_DB($Value) . " " . "WHERE " . $kk . "=" . StrSafe_DB($Id) . " AND " . $kk2 . "=" . StrSafe_DB($_SESSION['TourId']) . " " . ($kk3 ? " AND {$kk3} = " . StrSafe_DB($ClDivAllowed) : '');
$Rs = safe_w_sql($Update);
if (safe_w_affected_rows() and ($Field == 'ClAthlete' or $Field == 'DivAthlete')) {
// avvenuto un cambio di status di atleta!!!
if ($Value) {
if ($Field == 'ClAthlete') {
safe_w_sql("Update Entries left join Divisions on EnTournament=DivTournament and EnDivision=DivId set EnAthlete=DivAthlete+0 where EnTournament={$_SESSION['TourId']} and EnClass='{$Id}'");
} elseif ($Field == 'DivAthlete') {
safe_w_sql("Update Entries left join Classes on EnTournament=ClTournament and EnClass=ClId set EnAthlete=ClAthlete+0 where EnTournament={$_SESSION['TourId']} and EnDivision='{$Id}'");
}
} else {
if ($Field == 'ClAthlete') {
safe_w_sql("Update Entries set EnAthlete='' where EnTournament={$_SESSION['TourId']} and EnClass='{$Id}'");
} elseif ($Field == 'DivAthlete') {
safe_w_sql("Update Entries set EnAthlete='' where EnTournament={$_SESSION['TourId']} and EnDivision='{$Id}'");
}
}
}
示例8: NextPhaseInd
function NextPhaseInd($t = null, $e = null, $p = null, $m = null)
{
$tour = !is_null($t) ? $t : $_SESSION['TourId'];
$eventFilter = !is_null($e) ? "AND FinEvent=" . StrSafe_DB($e) . " " : "";
$joinFilter = "";
if (!is_null($p)) {
$joinFilter = " AND GrPhase=" . StrSafe_DB($p) . " ";
}
if (!is_null($m)) {
$m1 = -1;
$m2 = -1;
if ($m % 2 == 0) {
$m1 = $m;
$m2 = $m + 1;
} else {
$m1 = $m - 1;
$m2 = $m;
}
$joinFilter = "AND (GrMatchNo=" . $m1 . " OR GrMatchNo=" . $m2 . ") ";
}
$query = "";
$query = "SELECT CONCAT(EnFirstName,' ',SUBSTRING(EnName,1,1),'.') AS Atleta," . "CoCode,CoName," . "GrPhase,\t/* Grids*/ " . "FinMatchNo AS MatchNo,FinEvent AS `Event`, FinAthlete AS Athlete, FinScore AS Score,FinTie AS Tie, " . "IF(GrPhase>2, FLOOR(FinMatchNo/2),FLOOR(FinMatchNo/2)-2) AS NextMatchNo " . "FROM Finals INNER JOIN Grids ON FinMatchNo=GrMatchNo " . $joinFilter . " " . "LEFT JOIN Entries ON FinAthlete=EnId " . "WHERE FinTournament=" . StrSafe_DB($tour) . " " . $eventFilter . " " . "ORDER BY FinEvent, NextMatchNo ASC, FinScore DESC, FinTie DESC ";
$propagato = 0;
$athProp = 0;
$rs = safe_r_sql($query);
if (safe_num_rows($rs) && safe_num_rows($rs) % 2 == 0) {
while ($row0 = safe_fetch($rs)) {
$row1 = safe_fetch($rs);
$athProp = 0;
if ($row0->GrPhase >= 2) {
if (($row0->Score > 0 || $row0->Tie > 0) && ($row0->Score != $row1->Score || $row0->Tie != $row1->Tie)) {
$MyUpQuery = "UPDATE Finals SET ";
$MyUpQuery .= "FinAthlete =" . StrSafe_DB($row0->Athlete) . ", ";
$MyUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$MyUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row0->Event) . " AND FinMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND FinTournament=" . StrSafe_DB($tour) . " ";
$RsUp = safe_w_sql($MyUpQuery);
//print '1 ' . $MyUpQuery . '<br>';
$athProp = $row0->Athlete;
} else {
$MyUpQuery = "UPDATE Finals SET ";
$MyUpQuery .= "FinAthlete ='0', ";
$MyUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$MyUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row0->Event) . " AND FinMatchNo=" . StrSafe_DB($row0->NextMatchNo) . " AND FinTournament=" . StrSafe_DB($tour) . " ";
$RsUp = safe_w_sql($MyUpQuery);
//print '2 ' . $MyUpQuery . '<br>';
}
}
if ($row1->GrPhase == 2) {
if (($row1->Score > 0 || $row1->Tie > 0) && ($row0->Score != $row1->Score || $row0->Tie != $row1->Tie)) {
//print $row0->score.' - ' .$row1->score . ' + '. $row0->tie.' - ' .$row1->tie .'<br>';
$MyUpQuery = "UPDATE Finals SET ";
$MyUpQuery .= "FinAthlete =" . StrSafe_DB($row1->Athlete) . ", ";
$MyUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$MyUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row1->Event) . " AND FinMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND FinTournament=" . StrSafe_DB($tour) . " ";
$RsUp = safe_w_sql($MyUpQuery);
//print '3 ' . $MyUpQuery . '<br>';
$athProp = $row1->Athlete;
} else {
$MyUpQuery = "UPDATE Finals SET ";
$MyUpQuery .= "FinAthlete =" . StrSafe_DB($row1->Athlete) . ", ";
// 0
$MyUpQuery .= "FinDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " ";
$MyUpQuery .= "WHERE FinEvent=" . StrSafe_DB($row1->Event) . " AND FinMatchNo=" . StrSafe_DB($row1->NextMatchNo + 2) . " AND FinTournament=" . StrSafe_DB($tour) . " ";
$RsUp = safe_w_sql($MyUpQuery);
}
//print '4 ' . $MyUpQuery . '<br>';
}
}
// propagazione
$propaga = true;
if (!is_null($e) && !is_null($m) && $m <= 7) {
$propaga = false;
}
if ($propaga) {
$oldId = $athProp != 0 ? StrSafe_DB($row1->Athlete) : StrSafe_DB($row0->Athlete) . ',' . StrSafe_DB($row1->Athlete);
$Update = "UPDATE Finals SET " . "FinAthlete=" . StrSafe_DB($athProp) . " " . "WHERE FinAthlete IN (" . $oldId . ") AND FinTournament=" . StrSafe_DB($tour) . " AND FinEvent=" . StrSafe_DB($e) . " AND FinMatchNo<" . StrSafe_DB($row0->NextMatchNo) . " AND (FinScore<>0 OR FinTie<>0) ";
$RsProp = safe_w_sql($Update);
if (safe_w_affected_rows() > 0) {
$propagato = 1;
}
}
}
if (!is_null($e) && !is_null($m)) {
return array($row0, $row1, $athProp, $propagato);
} else {
return false;
}
}
示例9: define
<?php
define('debug', false);
// settare a true per l'output di debug
require_once dirname(dirname(__FILE__)) . '/config.php';
if (!CheckTourSession()) {
print get_text('CrackError');
exit;
}
$Errore = 2;
if (!IsBlocked(BIT_BLOCK_TOURDATA) and $q = safe_r_sql("select * from TargetFaces where TfTournament={$_SESSION['TourId']}") and safe_num_rows($q) > 1) {
// targets can be deleted only if there are targets left!
$delete = "DELETE FROM TargetFaces " . "WHERE TfTournament={$_SESSION['TourId']} AND TfId=" . intval($_REQUEST['tfid']);
$rs = safe_w_sql($delete);
$Errore = safe_w_affected_rows() ? 0 : 2;
}
if (!debug) {
header('Content-Type: text/xml');
}
print '<response>' . "\n";
print '<error>' . $Errore . '</error>' . "\n";
print '<row>' . $_REQUEST['row'] . '</row>' . "\n";
print '</response>' . "\n";
示例10: setRow
/**
* setRow().
* Imposta le IndRank degli elementi passati.
*
* Questo è il metodo da chiamare quando si risolvono gli spareggi perchè chi non passa ha la rank a posto
* grazie a calculate() e gli altri (sia quelli a cavallo che i buoni di sicuro) vanno impostati a mano.
*
*
* @param mixed $items: array degli elementi da scrivere.
* La struttra è la seguente:
* array(
* array(
* ath => <id> (chiave)
* event => <ev> (chiave)
* dist => <dist> (chiave)
* rank => <rank>
* tiebreak => <arrowstring>
* so => <so>
* )
* )
* con <id> l'id della persona <ev> l'evento, <arrowstring> l'arrowstring delle frecce di tie (opzionale), <dist> la distanza (0 vuol dire IndRank),
* <rank> la rank da impostare (opzionale), e e <so> prima degli spareggi vale come la rank se non ci sono spareggi; 0 per chi non passa e negativo come la rank in caso di gialli (opzionale).
* L'arrowstring, e l'so comunque sono considerati solo se <dist>==0
*
* Deve essere presente almeno un campo opzionale se no il metodo ritorna errore.
*
*
* @return mixed: ritorna le affected_rows oppure false se c'è qualche errore
* (non salva gli eventuali elementi successivi a quello che ha generato l'errore)
*/
public function setRow($items = array())
{
// campi mandatory per $item
$params = array('ath', 'event', 'dist');
$affected = 0;
foreach ($items as $item) {
/*print '<pre>';
print_r($item);
print '</pre>';*/
$paramsOk = true;
$canUp = false;
/*
* controllo che ci siano i campi mandatory
*/
foreach ($params as $p) {
if (!array_key_exists($p, $item)) {
$paramsOk = false;
$ret = false;
break;
}
}
if (!$paramsOk) {
continue;
}
$dd = $item['dist'] ? 'D' . $item['dist'] : '';
$date = date('Y-m-d H:i:s');
$q = "UPDATE " . "Individuals " . "SET " . "IndTimestamp='{$date}' ";
/* campi opzionali e basta */
if (array_key_exists('rank', $item)) {
$canUp = true;
$q .= ",Ind{$dd}Rank={$item['rank']}";
}
/*
* campi opzionali (se dist==0).
* In ogni caso i valori vengono scritti se e solo se la rank nuova è diversa dalla vecchia!
*/
if ($item['dist'] == 0) {
if (array_key_exists('tiebreak', $item)) {
$canUp = true;
$q .= ",IndTiebreak='{$item['tiebreak']}'";
}
if (array_key_exists('so', $item)) {
$canUp = true;
$q .= ",IndSO={$item['so']}";
}
}
$q .= " WHERE " . "IndId=" . $item['ath'] . " AND IndEvent='" . $item['event'] . "' AND IndTournament=" . $this->tournament . " ";
//print $q.'<br><br>';
if (!$canUp) {
return false;
}
$r = safe_w_sql($q);
if (!$r) {
$affected = false;
} else {
$affected += safe_w_affected_rows();
}
if (empty($item['fist']) && array_key_exists('rank', $item) && array_key_exists('hits', $item) && $item['hits'] % 3 == 0) {
$q = "INSERT INTO IndOldPositions (IopId, IopEvent, IopTournament, IopHits, IopRank) " . "VALUES(" . $item['ath'] . ",'" . $item['event'] . "'," . $this->tournament . "," . $item['hits'] . "," . $item['rank'] . ") " . "ON DUPLICATE KEY UPDATE IopRank=" . $item['rank'];
safe_w_sql($q);
}
}
return $affected;
}
示例11: safe_r_sql
$Rs = safe_r_sql($Select);
if (safe_num_rows($Rs) == 1) {
$MyRow = safe_fetch($Rs);
$OldValue = $MyRow->OldScore;
} else {
$Errore = 1;
}
if ($Errore == 0) {
// Aggiorno i totali della distanza
$Update = "UPDATE Qualifications SET " . "QuD" . $_REQUEST['Dist'] . "ArrowString=" . StrSafe_DB($ArrowString) . "," . "QuD" . $_REQUEST['Dist'] . "Score=" . StrSafe_DB($CurScore) . ", " . "QuD" . $_REQUEST['Dist'] . "Gold=" . StrSafe_DB($CurGold) . ", " . "QuD" . $_REQUEST['Dist'] . "Xnine=" . StrSafe_DB($CurXNine) . ", " . "QuD" . $_REQUEST['Dist'] . "Hits=" . StrSafe_DB(strlen(rtrim($ArrowString))) . ", " . "QuScore=QuD1Score+QuD2Score+QuD3Score+QuD4Score+QuD5Score+QuD6Score+QuD7Score+QuD8Score," . "QuGold=QuD1Gold+QuD2Gold+QuD3Gold+QuD4Gold+QuD5Gold+QuD6Gold+QuD7Gold+QuD8Gold," . "QuXnine=QuD1Xnine+QuD2Xnine+QuD3Xnine+QuD4Xnine+QuD5Xnine+QuD6Xnine+QuD7Xnine+QuD8Xnine, " . "QuHits=QuD1Hits+QuD2Hits+QuD3Hits+QuD4Hits+QuD5Hits+QuD6Hits+QuD7Hits+QuD8Hits, " . "QuTimestamp=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE QuId=" . StrSafe_DB($_REQUEST['Id']) . " ";
$RsUp = safe_w_sql($Update);
if (debug) {
print $Update . '<br>';
}
if ($PageOutput != 'JSON' or !$BlockApi) {
if (safe_w_affected_rows() == 1 && $OldValue != $CurScore) {
// Resetto il flag per gli spareggi
/*$Update
= "UPDATE Tournament SET "
. "ToMadeIndShootOff='0' "
. "WHERE ToId=" . StrSafe_DB($_SESSION['TourId']) . " ";
$Rs=safe_w_sql($Update);*/
// azzero gli shootoff
/*$Update
= "UPDATE Events INNER JOIN EventClass ON EvCode=EcCode AND (EvTeamEvent='0' OR EvTeamEvent='1') AND EcTournament=" . StrSafe_DB($_SESSION['TourId']) . " "
. "INNER JOIN Entries ON EcDivision=EnDivision AND EcClass=EnClass AND EnId=" . StrSafe_DB($_REQUEST['Id']) . " "
. "SET EvShootOff='0' "
. "WHERE (EvTeamEvent='0' AND EnIndFEvent='1') OR (EvTeamEvent='1' AND EnTeamFEvent='1') AND EvTournament=" . StrSafe_DB($_SESSION['TourId']) . " ";
$Rs=safe_w_sql($Update);
set_qual_session_flags();*/
$q = "\n\t\t\t\t\t\t\t\t\tSELECT DISTINCT EvCode,EvTeamEvent\n\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\tEvents\n\t\t\t\t\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t\t\t\t\t\tEventClass\n\t\t\t\t\t\t\t\t\t\tON EvCode=EcCode AND (EvTeamEvent='0' OR EvTeamEvent='1') AND EcTournament={$_SESSION['TourId']}\n\t\t\t\t\t\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t\t\t\t\t\tEntries\n\t\t\t\t\t\t\t\t\t\tON TRIM(EcDivision)=TRIM(EnDivision) AND TRIM(EcClass)=TRIM(EnClass) AND EnId={$_REQUEST['Id']}\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t (EvTeamEvent='0' AND EnIndFEvent='1') OR (EvTeamEvent='1' AND EnTeamFEvent='1') AND EvTournament={$_SESSION['TourId']}\n\t\t\t\t\t\t\t\t";
示例12: StrSafe_DB
}
} else {
$Errore = 1;
}
if (debug) {
print 'Errore prima di aggiornare: ' . $Errore . '<br>';
}
if ($Errore == 0) {
// scrivo il dato e aggiorno i totali
$Update = "UPDATE Eliminations SET " . $Cosa . "=" . StrSafe_DB($Value) . ", " . "ElDateTime=" . StrSafe_DB(date('Y-m-d H:i:s')) . " " . "WHERE ElId=" . StrSafe_DB($Atleta) . " AND ElElimPhase=" . StrSafe_DB($Fase);
$RsUp = safe_w_sql($Update);
if (debug) {
print $Update . ' <br><br>';
}
//print '..' . safe_w_affected_rows() . '<br>';
if (safe_w_affected_rows() == 1 && $OldValue != $Value) {
/*
* QUI il reset della fase successiva delle elim (se c'è)
* e il calcolo della rank elim della fase attuale.
*
* Se fase è 0 sicuramente ho anche la 1 perchè in caso di solo un girone l'unica fase buona è la 1
*/
$q = "SELECT ElEventCode FROM Eliminations WHERE ElId={$Atleta} AND ElElimPhase={$Fase}";
$r = safe_r_sql($q);
$ev = '';
$row = safe_fetch($r);
$ev = $row->ElEventCode;
if ($ev != '') {
if ($Fase == 0) {
ResetElimRows($ev, 2);
}
示例13: ArcherAssign
function ArcherAssign($Archer, $Target, $Country)
{
if (!empty($_REQUEST['DoAssign'])) {
$UpdateQry = "UPDATE Qualifications SET QuTargetNo=" . StrSafe_DB($_REQUEST['Session'] . $Target) . " WHERE QuId = {$Archer}";
$RsUpd = safe_w_sql($UpdateQry);
if (safe_w_affected_rows()) {
safe_w_sql("UPDATE Qualifications SET QuBacknoPrinted=0 WHERE QuId = {$Archer}");
}
}
$q = safe_r_sql("select * from Entries where EnID={$Archer}");
$r = safe_fetch($q);
return get_text('TargetAssigned', 'Tournament', $Target) . ' - ' . $Country . " - {$r->EnDivision}{$r->EnClass} ({$r->EnName} {$r->EnFirstName})";
}
示例14: safe_r_sql
$rs = safe_r_sql($query);
if ($rs) {
if (safe_num_rows($rs) == 1) {
$myRow = safe_fetch($rs);
if ($num4session < $myRow->HowMany + 1) {
$tooMany = 1;
$msg = get_text('NoMoreAth4Session', 'Tournament');
}
}
}
}
if ($tooMany == 0) {
$query = "UPDATE " . "Qualifications " . "SET " . "QuSession=" . StrSafe_DB($session) . " " . "WHERE " . "QuId=" . StrSafe_DB($id) . " ";
$rs = safe_w_sql($query);
// se la riga è stata aggiornata significa che la session è cambiata quindi annullo il target
if (safe_w_affected_rows() == 1) {
$query = "UPDATE " . "Qualifications " . "SET " . "QuTargetNo='', QuBacknoPrinted=0 " . "WHERE " . "QuId=" . StrSafe_DB($id) . " ";
$rs = safe_w_sql($query);
$resetTarget = 1;
}
}
} else {
$error = 1;
}
} else {
$error = 1;
}
} else {
$error = 1;
}
/****** End Controller ******/
示例15: get_text
print get_text('CrackError');
exit;
}
$Errore = intval(IsBlocked(BIT_BLOCK_TOURDATA) && !defined('dontEditClassDiv'));
$MsgErrore = '';
if (!$Errore) {
if (!is_numeric($_REQUEST['New_ClAgeFrom']) || !is_numeric($_REQUEST['New_ClAgeTo']) || $_REQUEST['New_ClAgeFrom'] <= 0 || $_REQUEST['New_ClAgeTo'] <= 0 || $_REQUEST['New_ClAgeFrom'] > $_REQUEST['New_ClAgeTo']) {
$Errore = 1;
}
}
if (!$Errore) {
// Aggiungo la nuova riga
$Insert = "INSERT IGNORE INTO Classes (ClId,ClTournament,ClDescription,ClAthlete,ClViewOrder,ClAgeFrom,ClAgeTo,ClValidClass,ClDivisionsAllowed,ClSex) " . "VALUES(" . StrSafe_DB($_REQUEST['New_ClId']) . "," . StrSafe_DB($_SESSION['TourId']) . "," . StrSafe_DB($_REQUEST['New_ClDescription']) . "," . StrSafe_DB(intval($_REQUEST['New_ClAthlete'])) . "," . StrSafe_DB($_REQUEST['New_ClViewOrder']) . ", " . StrSafe_DB($_REQUEST['New_ClAgeFrom']) . ", " . StrSafe_DB($_REQUEST['New_ClAgeTo']) . ", " . StrSafe_DB(CreateValidClass($_REQUEST['New_ClId'], $_REQUEST['New_ClValidClass'])) . ", " . StrSafe_DB($_REQUEST['New_ClValidDivision']) . ", " . StrSafe_DB($_REQUEST['New_ClSex']) . " " . ") ";
$RsIns = safe_w_sql($Insert);
//duplicate entries is OK
if (!safe_w_affected_rows()) {
$Errore = 2;
$MsgErrore = get_text('DuplicateEntry', 'Tournament');
}
}
header('Content-Type: text/xml');
print '<response>' . "\n";
print '<error>' . $Errore . '</error>' . "\n";
print '<errormsg><![CDATA[' . $MsgErrore . ']]></errormsg>' . "\n";
print '<new_clid><![CDATA[' . $_REQUEST['New_ClId'] . ']]></new_clid>' . "\n";
print '<new_cldescr><![CDATA[' . ManageHTML($_REQUEST['New_ClDescription']) . ']]></new_cldescr>' . "\n";
print '<new_clathleteyes><![CDATA[' . ManageHTML(get_text('Yes')) . ']]></new_clathleteyes>' . "\n";
print '<new_clathleteno><![CDATA[' . ManageHTML(get_text('No')) . ']]></new_clathleteno>' . "\n";
print '<new_clathlete><![CDATA[' . $_REQUEST['New_ClAthlete'] . ']]></new_clathlete>' . "\n";
print '<new_clprogr>' . $_REQUEST['New_ClViewOrder'] . '</new_clprogr>' . "\n";
print '<new_clagefrom>' . $_REQUEST['New_ClAgeFrom'] . '</new_clagefrom>' . "\n";