Location: PHPKode > projects > COWeb (Common Objects for Web) > coweb-0.4.1/include/news.inc.php
<?
// Module de gestion des news
// Ecrit par Sébastien DIAZ
// Distribue sous license GPL

include "coweb.inc.php";

if (! defined("NEWS"))
{
	define("NEWS",1);

	class news extends links
	{
		var $date;			// date de la news

		function news($id, $table)
		// Constructeur
		{

			if (isset($id))
			{
			 	$dbl=new db(server, port, database, login, password, type);
				$dbl->connect();
				$dbl->query("	SELECT id, label, url, description, flag, follow, param, date
						FROM $table
						WHERE id=$id"
						);
				$dbl->fetch();
				$this->id=stripslashes($dbl->row["id"]);
				$this->label=stripslashes($dbl->row["label"]);
				$this->url=stripslashes($dbl->row["url"]);				
				$this->description=stripslashes($dbl->row["description"]);				
				$this->flag=stripslashes($dbl->row["flag"]);
				$this->follow=stripslashes($dbl->row["follow"]);
				$this->param=stripslashes($dbl->row["param"]);
				$this->date=stripslashes($dbl->row["date"]);									
			}
			else 
			{
				$this->id="";
				$this->label="";
				$this->url="";
				$this->description="";
				$this->flag="1";
				$this->follow="";
				$this->param="";
				$this->date="";
			}
			$this->table=$table;
		}
	
		function Add()
		// Insertion d'une nouvelle News
		{
			$dbl=new db(server, port, database, login, password, type);
			$dbl->connect();
			$dbl->query("	INSERT $this->table
							VALUES ('', '$this->label', '$this->url', '$this->description', '1', '0', '', '$this->date')
						");
			$this->id=mysql_insert_id($dbl->id);
		}

		function Update()
		// Modification d'une News
		{
			$dbl=new db(server, port, database, login, password, type);
			$dbl->connect();
			$dbl->query("	UPDATE $this->table
							SET label='$this->label',
							url='$this->url',
							description='$this->description',
							flag='$this->flag',
							follow='$this->follow',
							param='$this->param',
							image='$this->date'
							WHERE id=$this->id
						");
			$dbl->fetch();
		}

		function Generate()
		// Creation d'une table de News
		{
			$dbl=new db(server, port, database, login, password, type);
			$dbl->Connect();
			$sql="	CREATE TABLE $this->table
					(
					id int(11) NOT NULL auto_increment,
					label varchar(64) default NULL,
					url tinytext,
					description tinytext,
					flag char(1) NOT NULL default '1',
					follow tinyint(4) NOT NULL default '0',
					param varchar(16) NOT NULL default '',
					date datetime default NULL,
					UNIQUE KEY id (id)
					)";
			$dbl->Query($sql);
		}
	
	}

}

?>
Return current item: COWeb (Common Objects for Web)