File: D:/HostingSpaces/NVonken/mijneigenlied.com/wwwroot/Core/Domain/NewsItemTranslation.php
<?php
/**
* Represents a news item translation
* @added 6-11-2012
* @modified 6-11-2012
* @author Thijs Bour
* @dependencies - Domain: NewsItem
* - Component: news.com.php
* - Element: news.element.php
*/
class NewsItemTranslation extends BaseClass
{
////////////////
// Properties //
////////////////
public $Id;
public $NewsItemId;
public $Lang;
public $Title;
public $Content;
public $Created;
public $Modified;
public static $_primaryKey = array("Id");
////////////////////
// Public Methods //
////////////////////
/**
* @param int $id
* @return NewsItemTranslation
*/
public static function Select($id)
{
return parent::Select($id);
}
/**
* Selects a list of News item translations
* @param int $newsItemId
* @param string $lang
* @param int|null $limit
* @return NewsItemTranslation[]
*/
public static function SelectByNewsItem($newsItemId, $lang, $limit = null)
{
$limitClause = "";
if ($limit != null && is_numeric($limit))
$limitClause = " LIMIT 0, " . $limit;
return parent::SelectObjects("SELECT *
FROM `NewsItemTranslation`
WHERE NewsItemId = '" . intval($newsItemId) . "'
AND Lang = '" . parent::_db()->escape($lang) . "'
ORDER BY Created DESC" . $limitClause);
}
/**
* Selects all NewsItemTranslation by NewsItemId
* @param int $newsItemId
* @return NewsItemTranslation[]
*/
public static function SelectAllByNewsItem($newsItemId)
{
return parent::SelectObjects("SELECT *
FROM `NewsItemTranslation`
WHERE NewsItemId = '" . intval($newsItemId) . "'");
}
/**
*
* @param int[] $newsItemIds
* @param string $lang
* @return NewsItemTranslation[]
*/
public static function SelectRange($newsItemIds, $lang)
{
if (count($newsItemIds) > 0) {
$range = join(",", $newsItemIds);
return parent::SelectObjects("SELECT *
FROM `NewsItemTranslation`
WHERE NewsItemId IN (" . $range . ")
AND Lang = '" . parent::_db()->escape($lang) . "'");
} else return array();
}
/**
* Inserts a NewsItemTranslation
* @return int
*/
public function Insert()
{
$this->Created = microtime(true);
$this->Modified = microtime(true);
return parent::Insert($this);
}
/**
* Updates a NewsItemTranslation
*/
public function Update()
{
$this->Modified = microtime(true);
parent::Update();
}
/**
* Deletes a NewsItem
*/
public function Delete()
{
parent::Delete();
}
/**
* Deletes NewsItemTranslations
*/
public static function DeleteByNewsItem($newsItemId)
{
parent::_db()->query("DELETE FROM
NewsItemTranslation
WHERE NewsItemId = '" . intval($newsItemId) . "'");
}
}
?>