Location: PHPKode > projects > Originator - RPG Rapid Prototyper > originator/includes/origin/deprecated/sql_location.php
<?php

/*
	Used in PLAY, EDIT, DISPLAY and CREATE Locations
		Needed to 

*/


class sql_location extends sql {
	/*
		returns an assoc arry of SCENE
	*/
	public function getLoc($locid) {
		$sql = "SELECT * from `originator`.`orig_location` WHERE `locid` = ". $locid;
		return self::fetchQuery($sql);
	}

	/*
		Pass an array to be parsed into the database. 
	*/
	public function insertLoc($loc){
		$sql = "INSERT INTO `originator`.`orig_location` (`locid`, `mapid`, `storyid`, `locview`, `loctitle`, `locdesc`, `graphic`,`createdby`, `createdon`, `lastupdate`) VALUES (NULL, NULL,'";
		$sql .= $loc['storyid'] ."','";
		$sql .= $loc['locview'] ."','";
		$sql .= $loc['loctitle'] ."','";
		$sql .= $loc['locdesc'] ."','";
		$sql .= $loc['graphic'] ."','";
		$sql .= $loc['createdby'] ."',";
		$sql .=" CURDATE(), CURDATE())";
		
		if (db::query($sql)) {
			return db::lastInsertId();
		} 
		return false;
	}
	
	/*
		Delete location method
	*/
	public function deleteLoc($storyid, $locid) {
		$sql = "DELETE from `orig_location` WHERE `storyid` = '". $storyid ."' AND `locid` = '". $locid ."'";
		
		if (0 == db::query($sql)->rowCount() ) {
			return false;
		} 
		return true;
	}
	/*
		Count of Scenes
	*/
	public function countScenes($chapterid, $locid) {
		$sql = "SELECT count(*) AS count FROM `orig_scene` WHERE `chapterid` = '". $chapterid ."'. AND `locid` = '". $locid."'";
		$count =self::fetchQuery($sql);
		return $count['count'];
	}
	
	/*
		Update method for existing stories. 
	*/
	public function update($loc){
		$setString  = ""; 
		
		foreach ($loc as $key=>$val){
			if ('chapterid' != $key || 'locid' != $key) {
				$setName .= "`" . $key ."` = '". $val ."'"; // may have to prep pre call 
			}
		}
		$sql = "UPDATE  `originator`.`orig_location` SET ". $setName ." WHERE  `locid` =".  $loc['locid'] ." AND `chapterid` =". $loc['chapterid'] ." LIMIT 1" ;
		return self::fetchQuery($sql);
	}

	/*
		translates database to XML for export
	*/
	public function toXML(){
		//TODO 
	}
}


?>
Return current item: Originator - RPG Rapid Prototyper