conn = DatabaseConnectionFactory::getConnection(); $this->conn->SetFetchMode(ADODB_FETCH_ASSOC); //$this->conn->debug = true; } function getList() { $sql = 'SELECT artistId,name FROM m_artist 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 artistId,name,profile,djMix ' . 'FROM m_artist ' . 'WHERE isValid = 1 ' . 'ORDER BY updated DESC ' . 'LIMIT ? OFFSET ?'; $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 findByArtistId (&$dto) { $sql = <<conn->prepare($sql); $rs = $this->conn->Execute($pstmt, array($dto->artistId)); $row = $rs->FetchRow(); $dto->name = $row['name']; $dto->profile = $row['profile']; $dto->djMix = $row['djMix']; $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->artistId = $row['artistId']; $dto->name = $row['name']; $dto->profile = $row['profile']; $dto->memberId = $row['memberId']; $dto->isValid = $row['isValid']; } function insert(&$dto) { $sql = <<name, $dto->profile, $dto->djMix, $dto->memberId, $dto->isValid, $dto->creator, $dto->updater ); $pstmt = $this->conn->prepare($sql); if ($this->conn->Execute($pstmt, array($data))) { $sql2 = 'select LAST_INSERT_ID() AS artistId'; $rs2 = $this->conn->Execute($sql2); $row = $rs2->FetchRow(); return $row['artistId']; } return; } function update(&$dto) { $sql = <<artistId, $dto->name, $dto->profile, $dto->djMix, $dto->memberId, $dto->isValid, $dto->updater, $dto->artistId, ); $pstmt = $this->conn->prepare($sql); $this->conn->Execute($pstmt, $data); } function delete($artistId, $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));
        }
	}
?>