[geeklog-cvs] Geeklog-2.x/plugins/content/models/om BaseGl2Content.php, NONE, 1.1 BaseGl2ContentPeer.php, NONE, 1.1
Damien Hodgkin
dhodgkin at qs1489.pair.com
Wed Aug 8 16:23:47 EDT 2007
Update of /cvsroot/geeklog2/Geeklog-2.x/plugins/content/models/om
In directory qs1489.pair.com:/tmp/cvs-serv13905/plugins/content/models/om
Added Files:
BaseGl2Content.php BaseGl2ContentPeer.php
Log Message:
Second commit
--- NEW FILE: BaseGl2Content.php ---
<?php
require_once 'propel/om/BaseObject.php';
require_once 'propel/om/Persistent.php';
include_once 'propel/util/Criteria.php';
include_once 'plugins/content/models/Gl2ContentPeer.php';
/**
* Base class that represents a row from the 'gl2_content' table.
*
*
*
* This class was autogenerated by Propel on:
*
* Fri Jul 27 14:15:18 2007
*
* @package plugins.content.models.om
*/
abstract class BaseGl2Content extends BaseObject implements Persistent {
/**
* The Peer class.
* Instance provides a convenient way of calling static methods on a class
* that calling code may not be able to identify.
* @var Gl2ContentPeer
*/
protected static $peer;
/**
* The value for the item_id field.
* @var int
*/
protected $item_id = 0;
/**
* The value for the content_id field.
* @var int
*/
protected $content_id;
/**
* The value for the content_author field.
* @var string
*/
protected $content_author = '';
/**
* The value for the content_title field.
* @var string
*/
protected $content_title = '';
/**
* The value for the description field.
* @var string
*/
protected $description;
/**
* The value for the content_body field.
* @var string
*/
protected $content_body;
/**
* The value for the content_url field.
* @var string
*/
protected $content_url = '';
/**
* The value for the content_type field.
* @var int
*/
protected $content_type = 0;
/**
* The value for the num_clicks field.
* @var int
*/
protected $num_clicks = 0;
/**
* @var Gl2Item
*/
protected $aGl2Item;
/**
* @var Gl2ListItem
*/
protected $aGl2ListItem;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInSave = false;
/**
* Flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInValidation = false;
/**
* Get the [item_id] column value.
*
* @return int
*/
public function getItemId()
{
return $this->item_id;
}
/**
* Get the [content_id] column value.
*
* @return int
*/
public function getContentId()
{
return $this->content_id;
}
/**
* Get the [content_author] column value.
*
* @return string
*/
public function getContentAuthor()
{
return $this->content_author;
}
/**
* Get the [content_title] column value.
*
* @return string
*/
public function getContentTitle()
{
return $this->content_title;
}
/**
* Get the [description] column value.
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Get the [content_body] column value.
*
* @return string
*/
public function getContentBody()
{
return $this->content_body;
}
/**
* Get the [content_url] column value.
*
* @return string
*/
public function getContentUrl()
{
return $this->content_url;
}
/**
* Get the [content_type] column value.
*
* @return int
*/
public function getContentType()
{
return $this->content_type;
}
/**
* Get the [num_clicks] column value.
*
* @return int
*/
public function getNumClicks()
{
return $this->num_clicks;
}
/**
* Set the value of [item_id] column.
*
* @param int $v new value
* @return void
*/
public function setItemId($v)
{
// Since the native PHP type for this column is integer,
// we will cast the input value to an int (if it is not).
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->item_id !== $v || $v === 0) {
$this->item_id = $v;
$this->modifiedColumns[] = Gl2ContentPeer::ITEM_ID;
}
if ($this->aGl2Item !== null && $this->aGl2Item->getItemId() !== $v) {
$this->aGl2Item = null;
}
} // setItemId()
/**
* Set the value of [content_id] column.
*
* @param int $v new value
* @return void
*/
public function setContentId($v)
{
// Since the native PHP type for this column is integer,
// we will cast the input value to an int (if it is not).
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->content_id !== $v) {
$this->content_id = $v;
$this->modifiedColumns[] = Gl2ContentPeer::CONTENT_ID;
}
} // setContentId()
/**
* Set the value of [content_author] column.
*
* @param string $v new value
* @return void
*/
public function setContentAuthor($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->content_author !== $v || $v === '') {
$this->content_author = $v;
$this->modifiedColumns[] = Gl2ContentPeer::CONTENT_AUTHOR;
}
} // setContentAuthor()
/**
* Set the value of [content_title] column.
*
* @param string $v new value
* @return void
*/
public function setContentTitle($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->content_title !== $v || $v === '') {
$this->content_title = $v;
$this->modifiedColumns[] = Gl2ContentPeer::CONTENT_TITLE;
}
} // setContentTitle()
/**
* Set the value of [description] column.
*
* @param string $v new value
* @return void
*/
public function setDescription($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->description !== $v) {
$this->description = $v;
$this->modifiedColumns[] = Gl2ContentPeer::DESCRIPTION;
}
} // setDescription()
/**
* Set the value of [content_body] column.
*
* @param string $v new value
* @return void
*/
public function setContentBody($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->content_body !== $v) {
$this->content_body = $v;
$this->modifiedColumns[] = Gl2ContentPeer::CONTENT_BODY;
}
} // setContentBody()
/**
* Set the value of [content_url] column.
*
* @param string $v new value
* @return void
*/
public function setContentUrl($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->content_url !== $v || $v === '') {
$this->content_url = $v;
$this->modifiedColumns[] = Gl2ContentPeer::CONTENT_URL;
}
} // setContentUrl()
/**
* Set the value of [content_type] column.
*
* @param int $v new value
* @return void
*/
public function setContentType($v)
{
// Since the native PHP type for this column is integer,
// we will cast the input value to an int (if it is not).
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->content_type !== $v || $v === 0) {
$this->content_type = $v;
$this->modifiedColumns[] = Gl2ContentPeer::CONTENT_TYPE;
}
if ($this->aGl2ListItem !== null && $this->aGl2ListItem->getListItemId() !== $v) {
$this->aGl2ListItem = null;
}
} // setContentType()
/**
* Set the value of [num_clicks] column.
*
* @param int $v new value
* @return void
*/
public function setNumClicks($v)
{
// Since the native PHP type for this column is integer,
// we will cast the input value to an int (if it is not).
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->num_clicks !== $v || $v === 0) {
$this->num_clicks = $v;
$this->modifiedColumns[] = Gl2ContentPeer::NUM_CLICKS;
}
} // setNumClicks()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (1-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
* @return int next starting column
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
$this->item_id = $rs->getInt($startcol + 0);
$this->content_id = $rs->getInt($startcol + 1);
$this->content_author = $rs->getString($startcol + 2);
$this->content_title = $rs->getString($startcol + 3);
$this->description = $rs->getString($startcol + 4);
$this->content_body = $rs->getString($startcol + 5);
$this->content_url = $rs->getString($startcol + 6);
$this->content_type = $rs->getInt($startcol + 7);
$this->num_clicks = $rs->getInt($startcol + 8);
$this->resetModified();
$this->setNew(false);
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 9; // 9 = Gl2ContentPeer::NUM_COLUMNS - Gl2ContentPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating Gl2Content object", $e);
}
}
/**
* Removes this object from datastore and sets delete attribute.
*
* @param Connection $con
* @return void
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(Gl2ContentPeer::DATABASE_NAME);
}
try {
$con->begin();
Gl2ContentPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Stores the object in the database. If the object is new,
* it inserts it; otherwise an update is performed. This method
* wraps the doSave() worker method in a transaction.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see doSave()
*/
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if ($con === null) {
$con = Propel::getConnection(Gl2ContentPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Stores the object in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave($con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aGl2Item !== null) {
if ($this->aGl2Item->isModified()) {
$affectedRows += $this->aGl2Item->save($con);
}
$this->setGl2Item($this->aGl2Item);
}
if ($this->aGl2ListItem !== null) {
if ($this->aGl2ListItem->isModified()) {
$affectedRows += $this->aGl2ListItem->save($con);
}
$this->setGl2ListItem($this->aGl2ListItem);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = Gl2ContentPeer::doInsert($this, $con);
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setContentId($pk); //[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows += Gl2ContentPeer::doUpdate($this, $con);
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
} // doSave()
/**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
protected $validationFailures = array();
/**
* Gets any ValidationFailed objects that resulted from last call to validate().
*
*
* @return array ValidationFailed[]
* @see validate()
*/
public function getValidationFailures()
{
return $this->validationFailures;
}
/**
* Validates the objects modified field values and all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
* @return boolean Whether all columns pass validation.
* @see doValidate()
* @see getValidationFailures()
*/
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aGl2Item !== null) {
if (!$this->aGl2Item->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aGl2Item->getValidationFailures());
}
}
if ($this->aGl2ListItem !== null) {
if (!$this->aGl2ListItem->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aGl2ListItem->getValidationFailures());
}
}
if (($retval = Gl2ContentPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(Gl2ContentPeer::DATABASE_NAME);
if ($this->isColumnModified(Gl2ContentPeer::ITEM_ID)) $criteria->add(Gl2ContentPeer::ITEM_ID, $this->item_id);
if ($this->isColumnModified(Gl2ContentPeer::CONTENT_ID)) $criteria->add(Gl2ContentPeer::CONTENT_ID, $this->content_id);
if ($this->isColumnModified(Gl2ContentPeer::CONTENT_AUTHOR)) $criteria->add(Gl2ContentPeer::CONTENT_AUTHOR, $this->content_author);
if ($this->isColumnModified(Gl2ContentPeer::CONTENT_TITLE)) $criteria->add(Gl2ContentPeer::CONTENT_TITLE, $this->content_title);
if ($this->isColumnModified(Gl2ContentPeer::DESCRIPTION)) $criteria->add(Gl2ContentPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(Gl2ContentPeer::CONTENT_BODY)) $criteria->add(Gl2ContentPeer::CONTENT_BODY, $this->content_body);
if ($this->isColumnModified(Gl2ContentPeer::CONTENT_URL)) $criteria->add(Gl2ContentPeer::CONTENT_URL, $this->content_url);
if ($this->isColumnModified(Gl2ContentPeer::CONTENT_TYPE)) $criteria->add(Gl2ContentPeer::CONTENT_TYPE, $this->content_type);
if ($this->isColumnModified(Gl2ContentPeer::NUM_CLICKS)) $criteria->add(Gl2ContentPeer::NUM_CLICKS, $this->num_clicks);
return $criteria;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(Gl2ContentPeer::DATABASE_NAME);
$criteria->add(Gl2ContentPeer::CONTENT_ID, $this->content_id);
return $criteria;
}
/**
* Returns the primary key for this object (row).
* @return int
*/
public function getPrimaryKey()
{
return $this->getContentId();
}
/**
* Generic method to set the primary key (content_id column).
*
* @param int $key Primary key.
* @return void
*/
public function setPrimaryKey($key)
{
$this->setContentId($key);
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of Gl2Content (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setItemId($this->item_id);
$copyObj->setContentAuthor($this->content_author);
$copyObj->setContentTitle($this->content_title);
$copyObj->setDescription($this->description);
$copyObj->setContentBody($this->content_body);
$copyObj->setContentUrl($this->content_url);
$copyObj->setContentType($this->content_type);
$copyObj->setNumClicks($this->num_clicks);
$copyObj->setNew(true);
$copyObj->setContentId(NULL); // this is a pkey column, so set to default value
}
/**
* Makes a copy of this object that will be inserted as a new row in table when saved.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @return Gl2Content Clone of current object.
* @throws PropelException
*/
public function copy($deepCopy = false)
{
// we use get_class(), because this might be a subclass
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
/**
* Returns a peer instance associated with this om.
*
* Since Peer classes are not to have any instance attributes, this method returns the
* same instance for all member of this class. The method could therefore
* be static, but this would prevent one from overriding the behavior.
*
* @return Gl2ContentPeer
*/
public function getPeer()
{
if (self::$peer === null) {
self::$peer = new Gl2ContentPeer();
}
return self::$peer;
}
/**
* Declares an association between this object and a Gl2Item object.
*
* @param Gl2Item $v
* @return void
* @throws PropelException
*/
public function setGl2Item($v)
{
if ($v === null) {
$this->setItemId('');
} else {
$this->setItemId($v->getItemId());
}
$this->aGl2Item = $v;
}
/**
* Get the associated Gl2Item object
*
* @param Connection Optional Connection object.
* @return Gl2Item The associated Gl2Item object.
* @throws PropelException
*/
public function getGl2Item($con = null)
{
// include the related Peer class
include_once 'models/om/BaseGl2ItemPeer.php';
if ($this->aGl2Item === null && ($this->item_id !== null)) {
$this->aGl2Item = Gl2ItemPeer::retrieveByPK($this->item_id, $con);
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = Gl2ItemPeer::retrieveByPK($this->item_id, $con);
$obj->addGl2Items($this);
*/
}
return $this->aGl2Item;
}
/**
* Declares an association between this object and a Gl2ListItem object.
*
* @param Gl2ListItem $v
* @return void
* @throws PropelException
*/
public function setGl2ListItem($v)
{
if ($v === null) {
$this->setContentType('');
} else {
$this->setContentType($v->getListItemId());
}
$this->aGl2ListItem = $v;
}
/**
* Get the associated Gl2ListItem object
*
* @param Connection Optional Connection object.
* @return Gl2ListItem The associated Gl2ListItem object.
* @throws PropelException
*/
public function getGl2ListItem($con = null)
{
// include the related Peer class
include_once 'models/om/BaseGl2ListItemPeer.php';
if ($this->aGl2ListItem === null && ($this->content_type !== null)) {
$this->aGl2ListItem = Gl2ListItemPeer::retrieveByPK($this->content_type, $con);
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = Gl2ListItemPeer::retrieveByPK($this->content_type, $con);
$obj->addGl2ListItems($this);
*/
}
return $this->aGl2ListItem;
}
} // BaseGl2Content
--- NEW FILE: BaseGl2ContentPeer.php ---
<?php
require_once 'propel/util/BasePeer.php';
// The object class -- needed for instanceof checks in this class.
// actual class may be a subclass -- as returned by Gl2ContentPeer::getOMClass()
include_once 'plugins/content/models/Gl2Content.php';
/**
* Base static class for performing query and update operations on the 'gl2_content' table.
*
*
*
* This class was autogenerated by Propel on:
*
* Fri Jul 27 14:15:18 2007
*
* @package plugins.content.models.om
*/
abstract class BaseGl2ContentPeer {
[...1117 lines suppressed...]
return $objs;
}
} // BaseGl2ContentPeer
// 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 {
BaseGl2ContentPeer::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.
require_once 'plugins/content/models/map/Gl2ContentMapBuilder.php';
Propel::registerMapBuilder('plugins.content.models.map.Gl2ContentMapBuilder');
}
More information about the geeklog-cvs
mailing list