Location: PHPKode > projects > RabbitBB - Online Web Storage Project > mywebdrive/PHP_CON/rename/DAORenameDir.php
<?PHP

class DAORenameDir
{
	var $db;
	var $db_table;
	var $db_field;

	function DAORenameDir()
	{
		global $db, $db_table, $db_field;
		$this->db = $db;
		$this->db_table = $db_table;
		$this->db_field = $db_field;
	}

	function renamedir($_dirid, $_rename, $_fullpath, $indexid, $_affdata)
	{
		$sqlq = "UPDATE ".$this->db_table['dirattr'].
			" SET dirname='".$_rename."', ".
			"fullpath='".$_fullpath."' WHERE id=".
			$_dirid;
		if ($this->db->sql_query($sqlq, BEGIN_TRANSACTION))
		{
			$sqlq="UPDATE ".$this->db_table['dirindex'].
				" SET dirname='".$_rename."' WHERE ".
				"id IN (";
			for ($i=0; $i<count($indexid); $i++)
			{
				if ($i>0)
					$sqlq.= ",";
				$sqlq.=$indexid[$i];
			}
			$sqlq.=")";
			if ($this->db->sql_query($sqlq))
			{
				for ($i=0; $i<count($_affdata); $i++)
				{
					if ($_affdata[$i]['type']==SFILE)
					{
						$sqlq = "UPDATE ".$this->db_table['fileattr'].
							" SET fullpath='".$_affdata[$i]['fullpath']."' WHERE ".
							" id=".$_affdata[$i]['id'];
						//echo($sqlq."<br />");
					}
					else
					{
						$sqlq = "UPDATE ".$this->db_table['dirattr'].
							" SET fullpath='".$_affdata[$i]['fullpath']."' WHERE ".
							" id=".$_affdata[$i]['id'];
						//echo($sqlq."<br />");
					}
					if (!$this->db->sql_query($sqlq))
					{
						$this->db->sql_query("", ROLLBACK);
						return false;
					}
				}
				$this->db->sql_query("", END_TRANSACTION);
				return true;
			}
			else
			{
				$this->db->sql_query("", ROLLBACK);
				return false;
			}
		}
		
	}
}

?>
Return current item: RabbitBB - Online Web Storage Project