<?php

/**
 * Subclass for representing a row from the 'tblspacefile' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Tblspacefile extends BaseTblspacefile
{
	/**
	 * Initializes internal state of Tblspacefile object.
	 * @see        parent::__construct()
	 */
	public function __construct()
	{
		// Make sure that parent constructor is always invoked, since that
		// is where any default values for this object are set.
		parent::__construct();
	}

  public function setFileName($v) {
    parent::setFileName($v);
    $dotPos = strrpos($v, '.');
    if ($dotPos !== false) $this->setFileType(strtolower(substr($v, $dotPos + 1)));
  }

  public function delete(PropelPDO $con = null) {
    $resId = $this->getFileResource();
    parent::delete($con);

    $c1 = new Criteria();
    $c1->add(TblspacefilePeer::FILE_RESOURCE, $resId);
    if (TblspacefilePeer::doCount($c1) == 0) {
      $tblres = TblspaceresourcePeer::retrieveByPk($resId);
      $tblres->delete($con);
    }
  }
}
