Changeset View
Changeset View
Standalone View
Standalone View
includes/class-QueryTrack.php
- This file was added.
<?php | |||||
# Linux Day Torino website - classes | |||||
# Copyright (C) 2020 Valerio Bozzolan | |||||
# | |||||
# This program is free software: you can redistribute it and/or modify | |||||
# it under the terms of the GNU Affero General Public License as published by | |||||
# the Free Software Foundation, either version 3 of the License, or | |||||
# (at your option) any later version. | |||||
# | |||||
# This program is distributed in the hope that it will be useful, | |||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
# GNU Affero General Public License for more details. | |||||
# | |||||
# You should have received a copy of the GNU Affero General Public License | |||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |||||
/** | |||||
* Methods related to a QueryTrack class | |||||
*/ | |||||
trait QueryTrackTrait { | |||||
/** | |||||
* Where the Track is... | |||||
* | |||||
* @param object $event Track | |||||
* @return self | |||||
*/ | |||||
public function whereTrack( $event ) { | |||||
return $this->whereTrackID( $event->getTrackID() ); | |||||
} | |||||
/** | |||||
* Where the Track ID is... | |||||
* | |||||
* @param int $id Track ID | |||||
* @return self | |||||
*/ | |||||
public function whereTrackID( $id ) { | |||||
return $this->whereInt( $this->TRACK_ID, $id ); | |||||
} | |||||
/** | |||||
* Join a generic table with the Track table | |||||
* | |||||
* @param string $type Join type | |||||
* @return self | |||||
*/ | |||||
public function joinTrack( $type = 'INNER' ) { | |||||
// build the: | |||||
// INNER JOIN track ON (track.track_ID = track_ID) | |||||
return $this->joinOn( $type, Track::T, Track::ID_, $this->TRACK_ID ); | |||||
} | |||||
} | |||||
/** | |||||
* Utility used to Query a Track. | |||||
*/ | |||||
class QueryTrack { | |||||
use QueryTrackTrait; | |||||
/** | |||||
* Full name of the column of the Track ID | |||||
*/ | |||||
protected $TRACK_ID = 'track_ID'; | |||||
/** | |||||
* Constructor | |||||
*/ | |||||
public function __construct() { | |||||
parent::__construct(); | |||||
$this->from( Track::T ); | |||||
$this->defaultClass( Track::class ); | |||||
} | |||||
} |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register