conn = DatabaseConnectionFactory::getConnection(); $this->conn->SetFetchMode(ADODB_FETCH_ASSOC); //$this->conn->debug = true; } function getList() { $sql = 'SELECT clubId,name FROM m_club WHERE isValid = 1'; $pstmt = $this->conn->prepare($sql); $rs = $this->conn->Execute($pstmt); if ($rs->EOF) { return null; } return $rs->getArray(); } function findByActive ($limit, $page = 1) { $offset = $limit * ($page - 1); $sql = 'SELECT clubId,name,address,information,accessInformation ' . 'FROM m_club ' . 'WHERE isValid = 1 ' . 'ORDER BY updated DESC ' . 'LIMIT ? OFFSET ?'; //$this->conn->debug = true; $pstmt = $this->conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($limit, $offset)); if ($rs->EOF) { return null; } return $rs->getArray(); } function findByClubId (&$dto) { $sql = <<conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($dto->clubId)); $row = $rs->FetchRow(); $dto->clubId = $row['clubId']; $dto->name = $row['name']; $dto->information = $row['information']; $dto->address = $row['address']; $dto->accessInformation = $row['accessInformation']; $dto->memberId = $row['memberId']; $dto->isValid = $row['isValid']; } function findByMemberId (&$dto) { $sql = <<conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($dto->memberId)); $row = $rs->FetchRow(); $dto->clubId = $row['clubId']; $dto->name = $row['name']; $dto->information = $row['information']; $dto->address = $row['address']; $dto->accessInformation = $row['accessInformation']; $dto->memberId = $row['memberId']; $dto->isValid = $row['isValid']; } function isExsist ($name) { $sql = <<conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($name)); $row = $rs->FetchRow(); return $row['count'] ? true : false; } function insert(&$dto) { $sql = <<name, $dto->information, $dto->address, $dto->accessInformation, $dto->memberId, $dto->isValid, $dto->creator, $dto->updater ); //$this->conn->debug = true; $pstmt = $this->conn->prepare($sql); if ($this->conn->Execute($pstmt, array($data))) { $sql2 = 'select LAST_INSERT_ID() AS clubId'; $rs2 = $this->conn->Execute($sql2); $row = $rs2->FetchRow(); return $row['clubId']; } return; } function update(&$dto) { $sql = <<clubId, $dto->name, $dto->information, $dto->address, $dto->accessInformation, $dto->memberId, $dto->isValid, $dto->creator, $dto->updater, $dto->clubId ); $pstmt = $this->conn->prepare($sql); $this->conn->Execute($pstmt, $data); } function delete($clubId, $updater) { $sql = <<conn->prepare($sql); $this->conn->Execute($pstmt, $data); } } ?>conn = DatabaseConnectionFactory::getConnection(); $this->conn->SetFetchMode(ADODB_FETCH_ASSOC); //$this->conn->debug = true; } function getList($memberId = null) { $sql = 'SELECT * FROM m_event WHERE isValid = 1 '; if ($memberId) { $sql .= 'AND memberId = ' . $memberId; } $sql .= ' ORDER BY date DESC'; $pstmt = $this->conn->prepare($sql); $rs = $this->conn->Execute($pstmt); if ($rs->EOF) { return null; } return $rs->getArray(); } function findByClubId ($clubId) { $sql1 = <<= now() ORDER BY m_event.date EOF; $pstmt1 = $this->conn->prepare($sql1); $rs1 = $this->conn->Execute($pstmt1, array($clubId)); if (!$rs1->EOF) { $list1 = $rs1->getArray(); } $sql2 = <<conn->prepare($sql2); $rs2 = $this->conn->Execute($pstmt2, array($clubId)); if (!$rs2->EOF) { $list2 = $rs2->getArray(); } $list = array_merge($list1, $list2); return $list; } function findByActive ($limit, $page = 1) { $offset = $limit * ($page - 1); $sql = <<= now() ORDER BY m_event.date LIMIT ? OFFSET ? EOF; $pstmt = $this->conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($limit,$offset)); if ($rs->EOF) { return null; } return $rs->getArray(); } function findNewEventList ($limit, $page = 1) { $offset = $limit * ($page - 1); $sql = <<= now() ORDER BY m_event.date LIMIT ? OFFSET ? EOF; $pstmt = $this->conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($limit,$offset)); if ($rs->EOF) { return null; } return $rs->getArray(); } function isExsist ($name) { $sql = <<conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($name)); $row = $rs->FetchRow(); return $row['count'] ? true : false; } function findByEventId (&$dto) { $sql = <<conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($dto->eventId)); $row = $rs->FetchRow(); $dto->name = $row['name']; $dto->clubId = $row['clubId']; $dto->date = $row['date']; $dto->information = $row['information']; $dto->nonMemberArtist = $row['nonMemberArtist']; $dto->report = $row['report']; $dto->isValid = $row['isValid']; $list = split('-', $row['date']); $dto->year = $list[0]; $dto->month = $list[1]; $dto->day = $list[2]; } function insert(&$dto) { $sql = <<name, $dto->clubId, $dto->date, $dto->information, $dto->nonMemberArtist, $dto->report, $dto->memberId, $dto->isValid, $dto->creator, $dto->updater ); //$this->conn->debug = true; $pstmt = $this->conn->prepare($sql); if ($this->conn->Execute($pstmt, array($data))) { $sql2 = 'select LAST_INSERT_ID() AS id'; $rs2 = $this->conn->Execute($sql2); $row = $rs2->FetchRow(); return $row['id']; } return; } function update(&$dto) { $sql = <<eventId, $dto->name, $dto->clubId, $dto->date, $dto->information, $dto->nonMemberArtist, $dto->report, $dto->memberId, $dto->isValid, $dto->updater, $dto->eventId ); $pstmt = $this->conn->prepare($sql); $this->conn->Execute($pstmt, $data); } function delete($eventId, $updater) { $sql = <<conn->prepare($sql); $this->conn->Execute($pstmt, $data); } } ?> conn = DatabaseConnectionFactory::getConnection(); $this->conn->SetFetchMode(ADODB_FETCH_ASSOC); //$this->conn->debug = true; } function findByArtistId($artistId) { // TODO LEFT JOINに変更 // new $sql1 = <<= now() AND B.eventId = C.eventId AND B.artistId = ? AND B.isValid = 1 ORDER BY C.date EOF; print "
";
			$pstmt1 = $this->conn->prepare($sql1);
			$rs1 = $this->conn->Execute($pstmt1, array($artistId));
			if ($rs1->EOF) {
				return null;
			}
			$list1 = $rs1->getArray();

			// new
			$sql2 = <<conn->prepare($sql2);
			$rs2 = $this->conn->Execute($pstmt2, array($artistId));
			if ($rs2->EOF) {
				return null;
			}
			$list2 = $rs2->getArray();
			$result = array_merge($list1, $list2);

			return $result;
		}		
		
		function findByEventId($eventId) {
			$sql = <<conn->prepare($sql);
			$rs = $this->conn->Execute($pstmt, array($eventId));
			if ($rs->EOF) {
				return null;
			}
			return $rs->getArray();
		}

		function isExsist ($eventId, $artistId)
		{
			$sql = <<conn->prepare($sql);
			$rs = $this->conn->Execute($pstmt, array($eventId, $artistId));
			$row = $rs->FetchRow();
			return $row['count'] ? true : false;
		}

		function insert($eventId, $artistId, $displayOrder = null,
										$isValid, $creator, $updater) {
			$sql = <<conn->prepare($sql);
			if ($this->conn->Execute($pstmt, array($data))) {
				return true;
			}
			return;
		}

		function update($eventId, $artistId, $displayOrder = null,
							$isValid, $updater) {
			$sql = <<conn->debug = true;
			$pstmt = $this->conn->prepare($sql);
			$this->conn->Execute($pstmt, $data);
		}
		
		function delete ($eventId, $artistId, $isValid) {
			$sql = <<conn->debug = true;
			$pstmt = $this->conn->prepare($sql);
			$this->conn->Execute($pstmt, array($eventId, $artistId, $isValid));
        }
	}
?>