first commit
This commit is contained in:
192
plugins/stSlideBannerPlugin/lib/model/SlideBanner.php
Normal file
192
plugins/stSlideBannerPlugin/lib/model/SlideBanner.php
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_slide_banner' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stSlideBannerPlugin.lib.model
|
||||
*/
|
||||
class SlideBanner extends BaseSlideBanner
|
||||
{
|
||||
public function getAdminGeneratorTitle()
|
||||
{
|
||||
return "Banner - {$this->getId()}";
|
||||
}
|
||||
|
||||
public function getBannerMarginLeft()
|
||||
{
|
||||
return !empty(parent::getBannerMarginLeft()) ? parent::getBannerMarginLeft() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [banner_margin_right] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBannerMarginRight()
|
||||
{
|
||||
return !empty(parent::getBannerMarginRight()) ? parent::getBannerMarginRight() : 0;
|
||||
}
|
||||
|
||||
public function genImagePath($image, $system_dir = false)
|
||||
{
|
||||
$path = "/picture/" . $this->getLanguage()->getOriginalLanguage() . '/' . $this->id . '-' . $image;
|
||||
|
||||
if ($system_dir)
|
||||
{
|
||||
return sfConfig::get('sf_upload_dir').$path;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function getImagePath($system_dir = false)
|
||||
{
|
||||
$path = 'uploads'.$this->getImage();
|
||||
|
||||
if ($system_dir)
|
||||
{
|
||||
return sfConfig::get('sf_web_dir').'/'.$path;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function getImageSmallPath($system_dir = false)
|
||||
{
|
||||
$path = 'uploads'.$this->getImageSmall();
|
||||
|
||||
if ($system_dir)
|
||||
{
|
||||
return sfConfig::get('sf_web_dir').'/'.$path;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function removeImage()
|
||||
{
|
||||
$path = $this->getImagePath(true);
|
||||
|
||||
if (is_file($path))
|
||||
{
|
||||
unlink($path);
|
||||
}
|
||||
|
||||
$this->setImage(null);
|
||||
}
|
||||
|
||||
public function removeImageSmall()
|
||||
{
|
||||
$path = $this->getImageSmallPath(true);
|
||||
|
||||
if (is_file($path))
|
||||
{
|
||||
unlink($path);
|
||||
}
|
||||
|
||||
$this->setImageSmall(null);
|
||||
}
|
||||
|
||||
public function moveUp()
|
||||
{
|
||||
$c = new Criteria();
|
||||
//$c->add(SlideBannerPeer::ID, $this->getId());
|
||||
|
||||
$c->add(SlideBannerPeer::RANK, $this->getRank(), Criteria::LESS_THAN);
|
||||
|
||||
$c->addDescendingOrderByColumn(SlideBannerPeer::RANK);
|
||||
|
||||
$previous = SlideBannerPeer::doSelectOne($c);
|
||||
|
||||
if ($previous)
|
||||
{
|
||||
$rank = $this->getRank();
|
||||
|
||||
$this->setRank($previous->getRank());
|
||||
|
||||
$previous->setRank($rank);
|
||||
|
||||
$previous->save();
|
||||
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function moveDown()
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->add(SlideBannerPeer::RANK, $this->getRank(), Criteria::GREATER_THAN);
|
||||
|
||||
$c->addAscendingOrderByColumn(SlideBannerPeer::RANK);
|
||||
|
||||
$next = SlideBannerPeer::doSelectOne($c);
|
||||
|
||||
if ($next)
|
||||
{
|
||||
$rank = $this->getRank();
|
||||
|
||||
$this->setRank($next->getRank());
|
||||
|
||||
$next->setRank($rank);
|
||||
|
||||
$next->save();
|
||||
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isNew())
|
||||
{
|
||||
$c = new Criteria();
|
||||
$banners = SlideBannerPeer::doSelect($c);
|
||||
|
||||
foreach ($banners as $banner) {
|
||||
$banner->setRank($banner->getRank()+1);
|
||||
$banner->save();
|
||||
}
|
||||
|
||||
$max_rank = SlideBannerPeer::doSelectMaxRank($this->getId());
|
||||
$this->setRank(1);
|
||||
}
|
||||
|
||||
if ($this->isColumnModified(SlideBannerPeer::LANGUAGE_ID))
|
||||
{
|
||||
$this->setOptCulture($this->getLanguage()->getOriginalLanguage());
|
||||
}
|
||||
|
||||
$ret = parent::save($con);
|
||||
SlideBannerPeer::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
$rank = $this->getRank();
|
||||
|
||||
$group_id = $this->getId();
|
||||
|
||||
$ret = parent::delete($con);
|
||||
|
||||
$this->removeImage();
|
||||
$this->removeImageSmall();
|
||||
SlideBannerPeer::clearCache();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function hasAbsoluteLink()
|
||||
{
|
||||
return $this->link[0] != '/';
|
||||
}
|
||||
|
||||
public function hasAbsoluteButtonLink()
|
||||
{
|
||||
return $this->button_link[0] != '/';
|
||||
}
|
||||
}
|
||||
56
plugins/stSlideBannerPlugin/lib/model/SlideBannerPeer.php
Normal file
56
plugins/stSlideBannerPlugin/lib/model/SlideBannerPeer.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_slide_banner' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stSlideBannerPlugin.lib.model
|
||||
*/
|
||||
class SlideBannerPeer extends BaseSlideBannerPeer
|
||||
{
|
||||
public static function doSelectSorted(Criteria $criteria, $con = null)
|
||||
{
|
||||
$c = clone $criteria;
|
||||
$c->addAscendingOrderByColumn(self::RANK);
|
||||
return self::doSelect($c);
|
||||
}
|
||||
|
||||
public static function moveAllUp($id, $from_rank)
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$query = sprintf('UPDATE %1$s SET %2$s = %2$s - 1 WHERE %3$s = ? AND %2$s > ?',
|
||||
self::TABLE_NAME,
|
||||
self::RANK,
|
||||
self::ID
|
||||
);
|
||||
|
||||
$stmt = $con->prepareStatement($query);
|
||||
$stmt->setInt(1, $id);
|
||||
$stmt->setInt(2, $from_rank);
|
||||
$stmt->executeQuery();
|
||||
}
|
||||
|
||||
public static function doSelectMaxRank($id)
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->addSelectColumn('MAX('.self::RANK.')');
|
||||
|
||||
$rs = BasePeer::doSelect($c, Propel::getConnection());
|
||||
|
||||
if ($rs->next())
|
||||
{
|
||||
return $rs->getInt(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function clearCache()
|
||||
{
|
||||
stPartialCache::clear('stSlideBannerFrontend', '_show', array('app' => 'frontend'));
|
||||
stFastCacheManager::clearCache();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_slide_banner' table to 'propel' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package plugins.stSlideBannerPlugin.lib.model.map
|
||||
*/
|
||||
class SlideBannerMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stSlideBannerPlugin.lib.model.map.SlideBannerMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('propel');
|
||||
|
||||
$tMap = $this->dbMap->addTable('st_slide_banner');
|
||||
$tMap->setPhpName('SlideBanner');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addForeignKey('LANGUAGE_ID', 'LanguageId', 'int', CreoleTypes::INTEGER, 'st_language', 'ID', true, null);
|
||||
|
||||
$tMap->addColumn('IMAGE', 'Image', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('IMAGE_SMALL', 'ImageSmall', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('VIDEO_MP4', 'VideoMp4', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('VIDEO_MP4_LINK', 'VideoMp4Link', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('BANNER_TYPE', 'BannerType', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('LINK', 'Link', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('GROUP_NAME', 'GroupName', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
$tMap->addColumn('BANNER_TITLE', 'BannerTitle', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('BANNER_DESCRIPTION', 'BannerDescription', 'string', CreoleTypes::LONGVARCHAR, false, null);
|
||||
|
||||
$tMap->addColumn('BUTTON_TEXT', 'ButtonText', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('BUTTON_LINK', 'ButtonLink', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('BANNER_DESCRIPTION_POSITION', 'BannerDescriptionPosition', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('BANNER_MARGIN_LEFT', 'BannerMarginLeft', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('BANNER_MARGIN_RIGHT', 'BannerMarginRight', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('BANNER_BG_TEXT', 'BannerBgText', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('BANNER_BG_OUT', 'BannerBgOut', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('BANNER_TEXT_ALIGN', 'BannerTextAlign', 'int', CreoleTypes::INTEGER, false, null);
|
||||
|
||||
$tMap->addColumn('IS_ACTIVE', 'IsActive', 'boolean', CreoleTypes::BOOLEAN, true, null);
|
||||
|
||||
$tMap->addColumn('OPT_CULTURE', 'OptCulture', 'string', CreoleTypes::VARCHAR, true, 7);
|
||||
|
||||
$tMap->addColumn('RANK', 'Rank', 'int', CreoleTypes::INTEGER, false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // SlideBannerMapBuilder
|
||||
1952
plugins/stSlideBannerPlugin/lib/model/om/BaseSlideBanner.php
Normal file
1952
plugins/stSlideBannerPlugin/lib/model/om/BaseSlideBanner.php
Normal file
File diff suppressed because it is too large
Load Diff
956
plugins/stSlideBannerPlugin/lib/model/om/BaseSlideBannerPeer.php
Normal file
956
plugins/stSlideBannerPlugin/lib/model/om/BaseSlideBannerPeer.php
Normal file
@@ -0,0 +1,956 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_slide_banner' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stSlideBannerPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BaseSlideBannerPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_slide_banner';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stSlideBannerPlugin.lib.model.SlideBanner';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 25;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the CREATED_AT field */
|
||||
const CREATED_AT = 'st_slide_banner.CREATED_AT';
|
||||
|
||||
/** the column name for the UPDATED_AT field */
|
||||
const UPDATED_AT = 'st_slide_banner.UPDATED_AT';
|
||||
|
||||
/** the column name for the ID field */
|
||||
const ID = 'st_slide_banner.ID';
|
||||
|
||||
/** the column name for the LANGUAGE_ID field */
|
||||
const LANGUAGE_ID = 'st_slide_banner.LANGUAGE_ID';
|
||||
|
||||
/** the column name for the IMAGE field */
|
||||
const IMAGE = 'st_slide_banner.IMAGE';
|
||||
|
||||
/** the column name for the IMAGE_SMALL field */
|
||||
const IMAGE_SMALL = 'st_slide_banner.IMAGE_SMALL';
|
||||
|
||||
/** the column name for the VIDEO_MP4 field */
|
||||
const VIDEO_MP4 = 'st_slide_banner.VIDEO_MP4';
|
||||
|
||||
/** the column name for the VIDEO_MP4_LINK field */
|
||||
const VIDEO_MP4_LINK = 'st_slide_banner.VIDEO_MP4_LINK';
|
||||
|
||||
/** the column name for the BANNER_TYPE field */
|
||||
const BANNER_TYPE = 'st_slide_banner.BANNER_TYPE';
|
||||
|
||||
/** the column name for the LINK field */
|
||||
const LINK = 'st_slide_banner.LINK';
|
||||
|
||||
/** the column name for the GROUP_NAME field */
|
||||
const GROUP_NAME = 'st_slide_banner.GROUP_NAME';
|
||||
|
||||
/** the column name for the DESCRIPTION field */
|
||||
const DESCRIPTION = 'st_slide_banner.DESCRIPTION';
|
||||
|
||||
/** the column name for the BANNER_TITLE field */
|
||||
const BANNER_TITLE = 'st_slide_banner.BANNER_TITLE';
|
||||
|
||||
/** the column name for the BANNER_DESCRIPTION field */
|
||||
const BANNER_DESCRIPTION = 'st_slide_banner.BANNER_DESCRIPTION';
|
||||
|
||||
/** the column name for the BUTTON_TEXT field */
|
||||
const BUTTON_TEXT = 'st_slide_banner.BUTTON_TEXT';
|
||||
|
||||
/** the column name for the BUTTON_LINK field */
|
||||
const BUTTON_LINK = 'st_slide_banner.BUTTON_LINK';
|
||||
|
||||
/** the column name for the BANNER_DESCRIPTION_POSITION field */
|
||||
const BANNER_DESCRIPTION_POSITION = 'st_slide_banner.BANNER_DESCRIPTION_POSITION';
|
||||
|
||||
/** the column name for the BANNER_MARGIN_LEFT field */
|
||||
const BANNER_MARGIN_LEFT = 'st_slide_banner.BANNER_MARGIN_LEFT';
|
||||
|
||||
/** the column name for the BANNER_MARGIN_RIGHT field */
|
||||
const BANNER_MARGIN_RIGHT = 'st_slide_banner.BANNER_MARGIN_RIGHT';
|
||||
|
||||
/** the column name for the BANNER_BG_TEXT field */
|
||||
const BANNER_BG_TEXT = 'st_slide_banner.BANNER_BG_TEXT';
|
||||
|
||||
/** the column name for the BANNER_BG_OUT field */
|
||||
const BANNER_BG_OUT = 'st_slide_banner.BANNER_BG_OUT';
|
||||
|
||||
/** the column name for the BANNER_TEXT_ALIGN field */
|
||||
const BANNER_TEXT_ALIGN = 'st_slide_banner.BANNER_TEXT_ALIGN';
|
||||
|
||||
/** the column name for the IS_ACTIVE field */
|
||||
const IS_ACTIVE = 'st_slide_banner.IS_ACTIVE';
|
||||
|
||||
/** the column name for the OPT_CULTURE field */
|
||||
const OPT_CULTURE = 'st_slide_banner.OPT_CULTURE';
|
||||
|
||||
/** the column name for the RANK field */
|
||||
const RANK = 'st_slide_banner.RANK';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('CreatedAt', 'UpdatedAt', 'Id', 'LanguageId', 'Image', 'ImageSmall', 'VideoMp4', 'VideoMp4Link', 'BannerType', 'Link', 'GroupName', 'Description', 'BannerTitle', 'BannerDescription', 'ButtonText', 'ButtonLink', 'BannerDescriptionPosition', 'BannerMarginLeft', 'BannerMarginRight', 'BannerBgText', 'BannerBgOut', 'BannerTextAlign', 'IsActive', 'OptCulture', 'Rank', ),
|
||||
BasePeer::TYPE_COLNAME => array (SlideBannerPeer::CREATED_AT, SlideBannerPeer::UPDATED_AT, SlideBannerPeer::ID, SlideBannerPeer::LANGUAGE_ID, SlideBannerPeer::IMAGE, SlideBannerPeer::IMAGE_SMALL, SlideBannerPeer::VIDEO_MP4, SlideBannerPeer::VIDEO_MP4_LINK, SlideBannerPeer::BANNER_TYPE, SlideBannerPeer::LINK, SlideBannerPeer::GROUP_NAME, SlideBannerPeer::DESCRIPTION, SlideBannerPeer::BANNER_TITLE, SlideBannerPeer::BANNER_DESCRIPTION, SlideBannerPeer::BUTTON_TEXT, SlideBannerPeer::BUTTON_LINK, SlideBannerPeer::BANNER_DESCRIPTION_POSITION, SlideBannerPeer::BANNER_MARGIN_LEFT, SlideBannerPeer::BANNER_MARGIN_RIGHT, SlideBannerPeer::BANNER_BG_TEXT, SlideBannerPeer::BANNER_BG_OUT, SlideBannerPeer::BANNER_TEXT_ALIGN, SlideBannerPeer::IS_ACTIVE, SlideBannerPeer::OPT_CULTURE, SlideBannerPeer::RANK, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('created_at', 'updated_at', 'id', 'language_id', 'image', 'image_small', 'video_mp4', 'video_mp4_link', 'banner_type', 'link', 'group_name', 'description', 'banner_title', 'banner_description', 'button_text', 'button_link', 'banner_description_position', 'banner_margin_left', 'banner_margin_right', 'banner_bg_text', 'banner_bg_out', 'banner_text_align', 'is_active', 'opt_culture', 'rank', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('CreatedAt' => 0, 'UpdatedAt' => 1, 'Id' => 2, 'LanguageId' => 3, 'Image' => 4, 'ImageSmall' => 5, 'VideoMp4' => 6, 'VideoMp4Link' => 7, 'BannerType' => 8, 'Link' => 9, 'GroupName' => 10, 'Description' => 11, 'BannerTitle' => 12, 'BannerDescription' => 13, 'ButtonText' => 14, 'ButtonLink' => 15, 'BannerDescriptionPosition' => 16, 'BannerMarginLeft' => 17, 'BannerMarginRight' => 18, 'BannerBgText' => 19, 'BannerBgOut' => 20, 'BannerTextAlign' => 21, 'IsActive' => 22, 'OptCulture' => 23, 'Rank' => 24, ),
|
||||
BasePeer::TYPE_COLNAME => array (SlideBannerPeer::CREATED_AT => 0, SlideBannerPeer::UPDATED_AT => 1, SlideBannerPeer::ID => 2, SlideBannerPeer::LANGUAGE_ID => 3, SlideBannerPeer::IMAGE => 4, SlideBannerPeer::IMAGE_SMALL => 5, SlideBannerPeer::VIDEO_MP4 => 6, SlideBannerPeer::VIDEO_MP4_LINK => 7, SlideBannerPeer::BANNER_TYPE => 8, SlideBannerPeer::LINK => 9, SlideBannerPeer::GROUP_NAME => 10, SlideBannerPeer::DESCRIPTION => 11, SlideBannerPeer::BANNER_TITLE => 12, SlideBannerPeer::BANNER_DESCRIPTION => 13, SlideBannerPeer::BUTTON_TEXT => 14, SlideBannerPeer::BUTTON_LINK => 15, SlideBannerPeer::BANNER_DESCRIPTION_POSITION => 16, SlideBannerPeer::BANNER_MARGIN_LEFT => 17, SlideBannerPeer::BANNER_MARGIN_RIGHT => 18, SlideBannerPeer::BANNER_BG_TEXT => 19, SlideBannerPeer::BANNER_BG_OUT => 20, SlideBannerPeer::BANNER_TEXT_ALIGN => 21, SlideBannerPeer::IS_ACTIVE => 22, SlideBannerPeer::OPT_CULTURE => 23, SlideBannerPeer::RANK => 24, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('created_at' => 0, 'updated_at' => 1, 'id' => 2, 'language_id' => 3, 'image' => 4, 'image_small' => 5, 'video_mp4' => 6, 'video_mp4_link' => 7, 'banner_type' => 8, 'link' => 9, 'group_name' => 10, 'description' => 11, 'banner_title' => 12, 'banner_description' => 13, 'button_text' => 14, 'button_link' => 15, 'banner_description_position' => 16, 'banner_margin_left' => 17, 'banner_margin_right' => 18, 'banner_bg_text' => 19, 'banner_bg_out' => 20, 'banner_text_align' => 21, 'is_active' => 22, 'opt_culture' => 23, 'rank' => 24, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, )
|
||||
);
|
||||
|
||||
protected static $hydrateMethod = null;
|
||||
|
||||
protected static $postHydrateMethod = null;
|
||||
|
||||
public static function setHydrateMethod($callback)
|
||||
{
|
||||
self::$hydrateMethod = $callback;
|
||||
}
|
||||
|
||||
public static function setPostHydrateMethod($callback)
|
||||
{
|
||||
self::$postHydrateMethod = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
return BasePeer::getMapBuilder('plugins.stSlideBannerPlugin.lib.model.map.SlideBannerMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = SlideBannerPeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. SlideBannerPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(SlideBannerPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::CREATED_AT);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::UPDATED_AT);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::LANGUAGE_ID);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::IMAGE);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::IMAGE_SMALL);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::VIDEO_MP4);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::VIDEO_MP4_LINK);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_TYPE);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::LINK);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::GROUP_NAME);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::DESCRIPTION);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_TITLE);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_DESCRIPTION);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BUTTON_TEXT);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BUTTON_LINK);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_DESCRIPTION_POSITION);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_MARGIN_LEFT);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_MARGIN_RIGHT);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_BG_TEXT);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_BG_OUT);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::BANNER_TEXT_ALIGN);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::IS_ACTIVE);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::OPT_CULTURE);
|
||||
|
||||
$criteria->addSelectColumn(SlideBannerPeer::RANK);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('SlideBannerPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'SlideBannerPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_slide_banner.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_slide_banner.ID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(SlideBannerPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(SlideBannerPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = SlideBannerPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return SlideBanner
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = SlideBannerPeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return SlideBanner[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return SlideBannerPeer::populateObjects(SlideBannerPeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
SlideBannerPeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
$rs = BasePeer::doSelect($criteria, $con);
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
|
||||
}
|
||||
|
||||
return $rs;
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = SlideBannerPeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining the related Language table
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinLanguage(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(SlideBannerPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(SlideBannerPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(SlideBannerPeer::LANGUAGE_ID, LanguagePeer::ID);
|
||||
|
||||
$rs = SlideBannerPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of SlideBanner objects pre-filled with their Language objects.
|
||||
*
|
||||
* @return SlideBanner[] Array of SlideBanner objects.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinLanguage(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
SlideBannerPeer::addSelectColumns($c);
|
||||
|
||||
LanguagePeer::addSelectColumns($c);
|
||||
|
||||
$c->addJoin(SlideBannerPeer::LANGUAGE_ID, LanguagePeer::ID);
|
||||
$rs = SlideBannerPeer::doSelectRs($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$obj1 = new SlideBanner();
|
||||
$startcol = $obj1->hydrate($rs);
|
||||
if ($obj1->getLanguageId())
|
||||
{
|
||||
|
||||
$obj2 = new Language();
|
||||
$obj2->hydrate($rs, $startcol);
|
||||
$obj2->addSlideBanner($obj1);
|
||||
}
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria, joining all related tables
|
||||
*
|
||||
* @param Criteria $c
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(SlideBannerPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(SlideBannerPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$criteria->addJoin(SlideBannerPeer::LANGUAGE_ID, LanguagePeer::ID);
|
||||
|
||||
$rs = SlideBannerPeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects a collection of SlideBanner objects pre-filled with all related objects.
|
||||
*
|
||||
* @return SlideBanner[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectJoinAll(Criteria $c, $con = null)
|
||||
{
|
||||
$c = clone $c;
|
||||
|
||||
// Set the correct dbName if it has not been overridden
|
||||
if ($c->getDbName() == Propel::getDefaultDB()) {
|
||||
$c->setDbName(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
SlideBannerPeer::addSelectColumns($c);
|
||||
$startcol2 = (SlideBannerPeer::NUM_COLUMNS - SlideBannerPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
|
||||
|
||||
LanguagePeer::addSelectColumns($c);
|
||||
$startcol3 = $startcol2 + LanguagePeer::NUM_COLUMNS;
|
||||
|
||||
$c->addJoin(SlideBannerPeer::LANGUAGE_ID, LanguagePeer::ID);
|
||||
|
||||
$rs = BasePeer::doSelect($c, $con);
|
||||
|
||||
if (self::$hydrateMethod)
|
||||
{
|
||||
return call_user_func(self::$hydrateMethod, $rs);
|
||||
}
|
||||
$results = array();
|
||||
|
||||
while($rs->next()) {
|
||||
|
||||
$omClass = SlideBannerPeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj1 = new $cls();
|
||||
$obj1->hydrate($rs);
|
||||
|
||||
|
||||
// Add objects for joined Language rows
|
||||
|
||||
$omClass = LanguagePeer::getOMClass();
|
||||
|
||||
|
||||
$cls = Propel::import($omClass);
|
||||
$obj2 = new $cls();
|
||||
$obj2->hydrate($rs, $startcol2);
|
||||
|
||||
$newObject = true;
|
||||
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
|
||||
$temp_obj1 = $results[$j];
|
||||
$temp_obj2 = $temp_obj1->getLanguage(); // CHECKME
|
||||
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
|
||||
$newObject = false;
|
||||
$temp_obj2->addSlideBanner($obj1); // CHECKME
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newObject) {
|
||||
$obj2->initSlideBanners();
|
||||
$obj2->addSlideBanner($obj1);
|
||||
}
|
||||
|
||||
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return SlideBannerPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a SlideBanner or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or SlideBanner object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseSlideBannerPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseSlideBannerPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from SlideBanner object
|
||||
}
|
||||
|
||||
$criteria->remove(SlideBannerPeer::ID); // remove pkey col since this table uses auto-increment
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseSlideBannerPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseSlideBannerPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a SlideBanner or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or SlideBanner object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
|
||||
foreach (sfMixer::getCallables('BaseSlideBannerPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BaseSlideBannerPeer', $values, $con);
|
||||
if (false !== $ret)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(SlideBannerPeer::ID);
|
||||
$selectCriteria->add(SlideBannerPeer::ID, $criteria->remove(SlideBannerPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is SlideBanner object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
|
||||
|
||||
foreach (sfMixer::getCallables('BaseSlideBannerPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BaseSlideBannerPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_slide_banner table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(SlideBannerPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a SlideBanner or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or SlideBanner object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(SlideBannerPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof SlideBanner) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(SlideBannerPeer::ID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given SlideBanner object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param SlideBanner $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(SlideBanner $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(SlideBannerPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(SlideBannerPeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
$res = BasePeer::doValidate(SlideBannerPeer::DATABASE_NAME, SlideBannerPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = SlideBannerPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
|
||||
$request->setError($col, $failed->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return SlideBanner
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(SlideBannerPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(SlideBannerPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = SlideBannerPeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return SlideBanner[]
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(SlideBannerPeer::ID, $pks, Criteria::IN);
|
||||
$objs = SlideBannerPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseSlideBannerPeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseSlideBannerPeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
Propel::registerMapBuilder('plugins.stSlideBannerPlugin.lib.model.map.SlideBannerMapBuilder');
|
||||
}
|
||||
Reference in New Issue
Block a user