本文整理汇总了PHP中Reservation::free方法的典型用法代码示例。如果您正苦于以下问题:PHP Reservation::free方法的具体用法?PHP Reservation::free怎么用?PHP Reservation::free使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reservation
的用法示例。
在下文中一共展示了Reservation::free方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFree
function testFree()
{
$doc = $author = 0;
$date = time() - 7 * 24 * 60 * 60;
$duration = 15 * 24 * 60 * 60;
$res = new Reservation($doc, $author, $date, $duration);
$res->free();
$this->assertTrue($res->isExpired());
}
示例2: competition_create
public static function competition_create($courts, $name, $from, $to, $fromt, $tot, $reservations_delete = false, $admin_username)
{
global $DB;
$ret = array();
if (!is_array($courts) || count($courts) == 0) {
$ret['success'] = false;
$ret['error'] = 'Nincs kiválasztva pálya!';
$ret['error_type'] = 1;
} elseif ($name == "") {
$ret['success'] = false;
$ret['error'] = 'A rendezvény nevének megadása kötelező!';
$ret['error_type'] = 2;
} elseif (strtotime($to) < strtotime($from)) {
$ret['success'] = false;
$ret['error'] = 'A dátum intervallum hibás!';
$ret['error_type'] = 3;
} elseif (TimeUnit::convert_to_minutes($tot) <= TimeUnit::convert_to_minutes($fromt)) {
$ret['success'] = false;
$ret['error'] = 'Az idő intervallum hibás!';
$ret['error_type'] = 4;
} else {
$where = '
(timeunits.date BETWEEN :from_date AND :to_date) AND
(
(timeunits.from>=:from AND timeunits.from<:to)
OR
(timeunits.to>:from AND timeunits.to<=:to)
) AND
timeunits.court_id IN (' . implode(',', $courts) . ')
';
$sql = '
SELECT
COUNT(*) as c
FROM timeunits
WHERE
' . $where . ' AND
reserved_by IS NOT NULL AND
1=1
';
$sth = $DB->prepare($sql);
$sth->bindParam(':from_date', $from, PDO::PARAM_STR);
$sth->bindParam(':to_date', $to, PDO::PARAM_STR);
$sth->bindParam(':from', $fromt, PDO::PARAM_STR);
$sth->bindParam(':to', $tot, PDO::PARAM_STR);
$sth->execute();
$c = $sth->fetchColumn();
if ($c > 0 && $reservations_delete === false) {
$ret['success'] = false;
$ret['error'] = 'A kijelölt időszakban van lefoglalt idősáv. A foglalások törléséhez pipálja be a "foglalások törlése" jelölőnégyzetet.';
$ret['error_type'] = 5;
} else {
if ($reservations_delete === true) {
// foglalások törlése
$sql = '
SELECT
reservations.*
FROM reservations
LEFT JOIN timeunits ON (reservations.timeunit_id=timeunits.id)
WHERE
' . $where . ' AND
reserved_by IS NOT NULL AND
1=1
';
$sth = $DB->prepare($sql);
$sth->bindParam(':from_date', $from, PDO::PARAM_STR);
$sth->bindParam(':to_date', $to, PDO::PARAM_STR);
$sth->bindParam(':from', $fromt, PDO::PARAM_STR);
$sth->bindParam(':to', $tot, PDO::PARAM_STR);
$sth->execute();
foreach ($sth->fetchAll() as $tmp) {
$res = new Reservation($tmp);
$res->load_timeunit();
$res->load_user();
$res->is_freeable(true);
$res->free($admin_username);
}
}
$sql = '
UPDATE timeunits
SET
comment=:name,
available=0
WHERE
' . $where . '
';
$sth = $DB->prepare($sql);
$sth->bindParam(':name', $name, PDO::PARAM_STR);
$sth->bindParam(':from_date', $from, PDO::PARAM_STR);
$sth->bindParam(':to_date', $to, PDO::PARAM_STR);
$sth->bindParam(':from', $fromt, PDO::PARAM_STR);
$sth->bindParam(':to', $tot, PDO::PARAM_STR);
$sth->execute();
$ret['success'] = true;
}
}
return $ret;
}