      1: <?php
      2:
      3: namespace Thelia\Model\om;
      4:
      5: use \BasePeer;
      6: use \Criteria;
      7: use \PDO;
      8: use \PDOStatement;
      9: use \Propel;
     10: use \PropelException;
     11: use \PropelPDO;
     12: use Thelia\Model\Lang;
     13: use Thelia\Model\LangPeer;
     14: use Thelia\Model\map\LangTableMap;
     15:
     16: /**
     17:  * Base static class for performing query and update operations on the 'lang' table.
     18:  *
     19:  *
     20:  *
     21:  * @package propel.generator.Thelia.Model.om
     22:  */
     23: abstract class BaseLangPeer
     24: {
     25:
     26:     /** the default database name for this class */
     27:     const DATABASE_NAME = 'thelia';
     28:
     29:     /** the table name for this class */
     30:     const TABLE_NAME = 'lang';
     31:
     32:     /** the related Propel class for this table */
     33:     const OM_CLASS = 'Thelia\\Model\\Lang';
     34:
     35:     /** the related TableMap class for this table */
     36:     const TM_CLASS = 'LangTableMap';
     37:
     38:     /** The total number of columns. */
     39:     const NUM_COLUMNS = 8;
     40:
     41:     /** The number of lazy-loaded columns. */
     42:     const NUM_LAZY_LOAD_COLUMNS = 0;
     43:
     44:     /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
     45:     const NUM_HYDRATE_COLUMNS = 8;
     46:
     47:     /** the column name for the id field */
     48:     const ID = 'lang.id';
     49:
     50:     /** the column name for the title field */
     51:     const TITLE = 'lang.title';
     52:
     53:     /** the column name for the code field */
     54:     const CODE = 'lang.code';
     55:
     56:     /** the column name for the locale field */
     57:     const LOCALE = 'lang.locale';
     58:
     59:     /** the column name for the url field */
     60:     const URL = 'lang.url';
     61:
     62:     /** the column name for the by_default field */
     63:     const BY_DEFAULT = 'lang.by_default';
     64:
     65:     /** the column name for the created_at field */
     66:     const CREATED_AT = 'lang.created_at';
     67:
     68:     /** the column name for the updated_at field */
     69:     const UPDATED_AT = 'lang.updated_at';
     70:
     71:     /** The default string format for model objects of the related table **/
     72:     const DEFAULT_STRING_FORMAT = 'YAML';
     73:
     74:     /**
     75:      * An identiy map to hold any loaded instances of Lang objects.
     76:      * This must be public so that other peer classes can access this when hydrating from JOIN
     77:      * queries.
     78:      * @var        array Lang[]
     79:      */
     80:     public static $instances = array();
     81:
     82:
     83:     /**
     84:      * holds an array of fieldnames
     85:      *
     86:      * first dimension keys are the type constants
     87:      * e.g. LangPeer::$fieldNames[LangPeer::TYPE_PHPNAME][0] = 'Id'
     88:      */
     89:     protected static $fieldNames = array (
     90:         BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Code', 'Locale', 'Url', 'ByDefault', 'CreatedAt', 'UpdatedAt', ),
     91:         BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'title', 'code', 'locale', 'url', 'byDefault', 'createdAt', 'updatedAt', ),
     92:         BasePeer::TYPE_COLNAME => array (LangPeer::ID, LangPeer::TITLE, LangPeer::CODE, LangPeer::LOCALE, LangPeer::URL, LangPeer::BY_DEFAULT, LangPeer::CREATED_AT, LangPeer::UPDATED_AT, ),
     93:         BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TITLE', 'CODE', 'LOCALE', 'URL', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ),
     94:         BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'code', 'locale', 'url', 'by_default', 'created_at', 'updated_at', ),
     95:         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
     96:     );
     97:
     98:     /**
     99:      * holds an array of keys for quick access to the fieldnames array
    100:      *
    101:      * first dimension keys are the type constants
    102:      * e.g. LangPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
    103:      */
    104:     protected static $fieldKeys = array (
    105:         BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Code' => 2, 'Locale' => 3, 'Url' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ),
    106:         BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ),
    107:         BasePeer::TYPE_COLNAME => array (LangPeer::ID => 0, LangPeer::TITLE => 1, LangPeer::CODE => 2, LangPeer::LOCALE => 3, LangPeer::URL => 4, LangPeer::BY_DEFAULT => 5, LangPeer::CREATED_AT => 6, LangPeer::UPDATED_AT => 7, ),
    108:         BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'LOCALE' => 3, 'URL' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ),
    109:         BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ),
    110:         BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, )
    111:     );
    112:
    113:     /**
    114:      * Translates a fieldname to another type
    115:      *
    116:      * @param      string $name field name
    117:      * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
    118:      *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
    119:      * @param      string $toType   One of the class type constants
    120:      * @return string          translated name of the field.
    121:      * @throws PropelException - if the specified name could not be found in the fieldname mappings.
    122:      */
    123:     public static function translateFieldName($name, $fromType, $toType)
    124:     {
    125:         $toNames = LangPeer::getFieldNames($toType);
    126:         $key = isset(LangPeer::$fieldKeys[$fromType][$name]) ? LangPeer::$fieldKeys[$fromType][$name] : null;
    127:         if ($key === null) {
    128:             throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(LangPeer::$fieldKeys[$fromType], true));
    129:         }
    130:
    131:         return $toNames[$key];
    132:     }
    133:
    134:     /**
    135:      * Returns an array of field names.
    136:      *
    137:      * @param      string $type The type of fieldnames to return:
    138:      *                      One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
    139:      *                      BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
    140:      * @return array           A list of field names
    141:      * @throws PropelException - if the type is not valid.
    142:      */
    143:     public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
    144:     {
    145:         if (!array_key_exists($type, LangPeer::$fieldNames)) {
    146:             throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
    147:         }
    148:
    149:         return LangPeer::$fieldNames[$type];
    150:     }
    151:
    152:     /**
    153:      * Convenience method which changes table.column to alias.column.
    154:      *
    155:      * Using this method you can maintain SQL abstraction while using column aliases.
    156:      * <code>
    157:      *      $c->addAlias("alias1", TablePeer::TABLE_NAME);
    158:      *      $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
    159:      * </code>
    160:      * @param      string $alias The alias for the current table.
    161:      * @param      string $column The column name for current table. (i.e. LangPeer::COLUMN_NAME).
    162:      * @return string
    163:      */
    164:     public static function alias($alias, $column)
    165:     {
    166:         return str_replace(LangPeer::TABLE_NAME.'.', $alias.'.', $column);
    167:     }
    168:
    169:     /**
    170:      * Add all the columns needed to create a new object.
    171:      *
    172:      * Note: any columns that were marked with lazyLoad="true" in the
    173:      * XML schema will not be added to the select list and only loaded
    174:      * on demand.
    175:      *
    176:      * @param      Criteria $criteria object containing the columns to add.
    177:      * @param      string   $alias    optional table alias
    178:      * @throws PropelException Any exceptions caught during processing will be
    179:      *       rethrown wrapped into a PropelException.
    180:      */
    181:     public static function addSelectColumns(Criteria $criteria, $alias = null)
    182:     {
    183:         if (null === $alias) {
    184:             $criteria->addSelectColumn(LangPeer::ID);
    185:             $criteria->addSelectColumn(LangPeer::TITLE);
    186:             $criteria->addSelectColumn(LangPeer::CODE);
    187:             $criteria->addSelectColumn(LangPeer::LOCALE);
    188:             $criteria->addSelectColumn(LangPeer::URL);
    189:             $criteria->addSelectColumn(LangPeer::BY_DEFAULT);
    190:             $criteria->addSelectColumn(LangPeer::CREATED_AT);
    191:             $criteria->addSelectColumn(LangPeer::UPDATED_AT);
    192:         } else {
    193:             $criteria->addSelectColumn($alias . '.id');
    194:             $criteria->addSelectColumn($alias . '.title');
    195:             $criteria->addSelectColumn($alias . '.code');
    196:             $criteria->addSelectColumn($alias . '.locale');
    197:             $criteria->addSelectColumn($alias . '.url');
    198:             $criteria->addSelectColumn($alias . '.by_default');
    199:             $criteria->addSelectColumn($alias . '.created_at');
    200:             $criteria->addSelectColumn($alias . '.updated_at');
    201:         }
    202:     }
    203:
    204:     /**
    205:      * Returns the number of rows matching criteria.
    206:      *
    207:      * @param      Criteria $criteria
    208:      * @param      boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
    209:      * @param      PropelPDO $con
    210:      * @return int Number of matching rows.
    211:      */
    212:     public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
    213:     {
    214:         // we may modify criteria, so copy it first
    215:         $criteria = clone $criteria;
    216:
    217:         // We need to set the primary table name, since in the case that there are no WHERE columns
    218:         // it will be impossible for the BasePeer::createSelectSql() method to determine which
    219:         // tables go into the FROM clause.
    220:         $criteria->setPrimaryTableName(LangPeer::TABLE_NAME);
    221:
    222:         if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
    223:             $criteria->setDistinct();
    224:         }
    225:
    226:         if (!$criteria->hasSelectClause()) {
    227:             LangPeer::addSelectColumns($criteria);
    228:         }
    229:
    230:         $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
    231:         $criteria->setDbName(LangPeer::DATABASE_NAME); // Set the correct dbName
    232:
    233:         if ($con === null) {
    234:             $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    235:         }
    236:         // BasePeer returns a PDOStatement
    237:         $stmt = BasePeer::doCount($criteria, $con);
    238:
    239:         if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    240:             $count = (int) $row[0];
    241:         } else {
    242:             $count = 0; // no rows returned; we infer that means 0 matches.
    243:         }
    244:         $stmt->closeCursor();
    245:
    246:         return $count;
    247:     }
    248:     /**
    249:      * Selects one object from the DB.
    250:      *
    251:      * @param      Criteria $criteria object used to create the SELECT statement.
    252:      * @param      PropelPDO $con
    253:      * @return                 Lang
    254:      * @throws PropelException Any exceptions caught during processing will be
    255:      *       rethrown wrapped into a PropelException.
    256:      */
    257:     public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
    258:     {
    259:         $critcopy = clone $criteria;
    260:         $critcopy->setLimit(1);
    261:         $objects = LangPeer::doSelect($critcopy, $con);
    262:         if ($objects) {
    263:             return $objects[0];
    264:         }
    265:
    266:         return null;
    267:     }
    268:     /**
    269:      * Selects several row from the DB.
    270:      *
    271:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
    272:      * @param      PropelPDO $con
    273:      * @return array           Array of selected Objects
    274:      * @throws PropelException Any exceptions caught during processing will be
    275:      *       rethrown wrapped into a PropelException.
    276:      */
    277:     public static function doSelect(Criteria $criteria, PropelPDO $con = null)
    278:     {
    279:         return LangPeer::populateObjects(LangPeer::doSelectStmt($criteria, $con));
    280:     }
    281:     /**
    282:      * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
    283:      *
    284:      * Use this method directly if you want to work with an executed statement directly (for example
    285:      * to perform your own object hydration).
    286:      *
    287:      * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
    288:      * @param      PropelPDO $con The connection to use
    289:      * @throws PropelException Any exceptions caught during processing will be
    290:      *       rethrown wrapped into a PropelException.
    291:      * @return PDOStatement The executed PDOStatement object.
    292:      * @see        BasePeer::doSelect()
    293:      */
    294:     public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
    295:     {
    296:         if ($con === null) {
    297:             $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    298:         }
    299:
    300:         if (!$criteria->hasSelectClause()) {
    301:             $criteria = clone $criteria;
    302:             LangPeer::addSelectColumns($criteria);
    303:         }
    304:
    305:         // Set the correct dbName
    306:         $criteria->setDbName(LangPeer::DATABASE_NAME);
    307:
    308:         // BasePeer returns a PDOStatement
    309:         return BasePeer::doSelect($criteria, $con);
    310:     }
    311:     /**
    312:      * Adds an object to the instance pool.
    313:      *
    314:      * Propel keeps cached copies of objects in an instance pool when they are retrieved
    315:      * from the database.  In some cases -- especially when you override doSelect*()
    316:      * methods in your stub classes -- you may need to explicitly add objects
    317:      * to the cache in order to ensure that the same objects are always returned by doSelect*()
    318:      * and retrieveByPK*() calls.
    319:      *
    320:      * @param      Lang $obj A Lang object.
    321:      * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
    322:      */
    323:     public static function addInstanceToPool($obj, $key = null)
    324:     {
    325:         if (Propel::isInstancePoolingEnabled()) {
    326:             if ($key === null) {
    327:                 $key = (string) $obj->getId();
    328:             } // if key === null
    329:             LangPeer::$instances[$key] = $obj;
    330:         }
    331:     }
    332:
    333:     /**
    334:      * Removes an object from the instance pool.
    335:      *
    336:      * Propel keeps cached copies of objects in an instance pool when they are retrieved
    337:      * from the database.  In some cases -- especially when you override doDelete
    338:      * methods in your stub classes -- you may need to explicitly remove objects
    339:      * from the cache in order to prevent returning objects that no longer exist.
    340:      *
    341:      * @param      mixed $value A Lang object or a primary key value.
    342:      *
    343:      * @return void
    344:      * @throws PropelException - if the value is invalid.
    345:      */
    346:     public static function removeInstanceFromPool($value)
    347:     {
    348:         if (Propel::isInstancePoolingEnabled() && $value !== null) {
    349:             if (is_object($value) && $value instanceof Lang) {
    350:                 $key = (string) $value->getId();
    351:             } elseif (is_scalar($value)) {
    352:                 // assume we've been passed a primary key
    353:                 $key = (string) $value;
    354:             } else {
    355:                 $e = new PropelException("Invalid value passed to removeInstanceFromPool().  Expected primary key or Lang object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
    356:                 throw $e;
    357:             }
    358:
    359:             unset(LangPeer::$instances[$key]);
    360:         }
    361:     } // removeInstanceFromPool()
    362:
    363:     /**
    364:      * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
    365:      *
    366:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
    367:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
    368:      *
    369:      * @param      string $key The key (@see getPrimaryKeyHash()) for this instance.
    370:      * @return   Lang Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
    371:      * @see        getPrimaryKeyHash()
    372:      */
    373:     public static function getInstanceFromPool($key)
    374:     {
    375:         if (Propel::isInstancePoolingEnabled()) {
    376:             if (isset(LangPeer::$instances[$key])) {
    377:                 return LangPeer::$instances[$key];
    378:             }
    379:         }
    380:
    381:         return null; // just to be explicit
    382:     }
    383:
    384:     /**
    385:      * Clear the instance pool.
    386:      *
    387:      * @return void
    388:      */
    389:     public static function clearInstancePool($and_clear_all_references = false)
    390:     {
    391:       if ($and_clear_all_references)
    392:       {
    393:         foreach (LangPeer::$instances as $instance)
    394:         {
    395:           $instance->clearAllReferences(true);
    396:         }
    397:       }
    398:         LangPeer::$instances = array();
    399:     }
    400:
    401:     /**
    402:      * Method to invalidate the instance pool of all tables related to lang
    403:      * by a foreign key with ON DELETE CASCADE
    404:      */
    405:     public static function clearRelatedInstancePool()
    406:     {
    407:     }
    408:
    409:     /**
    410:      * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
    411:      *
    412:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
    413:      * a multi-column primary key, a serialize()d version of the primary key will be returned.
    414:      *
    415:      * @param      array $row PropelPDO resultset row.
    416:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    417:      * @return string A string version of PK or null if the components of primary key in result array are all null.
    418:      */
    419:     public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
    420:     {
    421:         // If the PK cannot be derived from the row, return null.
    422:         if ($row[$startcol] === null) {
    423:             return null;
    424:         }
    425:
    426:         return (string) $row[$startcol];
    427:     }
    428:
    429:     /**
    430:      * Retrieves the primary key from the DB resultset row
    431:      * For tables with a single-column primary key, that simple pkey value will be returned.  For tables with
    432:      * a multi-column primary key, an array of the primary key columns will be returned.
    433:      *
    434:      * @param      array $row PropelPDO resultset row.
    435:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    436:      * @return mixed The primary key of the row
    437:      */
    438:     public static function getPrimaryKeyFromRow($row, $startcol = 0)
    439:     {
    440:
    441:         return (int) $row[$startcol];
    442:     }
    443:
    444:     /**
    445:      * The returned array will contain objects of the default type or
    446:      * objects that inherit from the default.
    447:      *
    448:      * @throws PropelException Any exceptions caught during processing will be
    449:      *       rethrown wrapped into a PropelException.
    450:      */
    451:     public static function populateObjects(PDOStatement $stmt)
    452:     {
    453:         $results = array();
    454:
    455:         // set the class once to avoid overhead in the loop
    456:         $cls = LangPeer::getOMClass();
    457:         // populate the object(s)
    458:         while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
    459:             $key = LangPeer::getPrimaryKeyHashFromRow($row, 0);
    460:             if (null !== ($obj = LangPeer::getInstanceFromPool($key))) {
    461:                 // We no longer rehydrate the object, since this can cause data loss.
    462:                 // See http://www.propelorm.org/ticket/509
    463:                 // $obj->hydrate($row, 0, true); // rehydrate
    464:                 $results[] = $obj;
    465:             } else {
    466:                 $obj = new $cls();
    467:                 $obj->hydrate($row);
    468:                 $results[] = $obj;
    469:                 LangPeer::addInstanceToPool($obj, $key);
    470:             } // if key exists
    471:         }
    472:         $stmt->closeCursor();
    473:
    474:         return $results;
    475:     }
    476:     /**
    477:      * Populates an object of the default type or an object that inherit from the default.
    478:      *
    479:      * @param      array $row PropelPDO resultset row.
    480:      * @param      int $startcol The 0-based offset for reading from the resultset row.
    481:      * @throws PropelException Any exceptions caught during processing will be
    482:      *       rethrown wrapped into a PropelException.
    483:      * @return array (Lang object, last column rank)
    484:      */
    485:     public static function populateObject($row, $startcol = 0)
    486:     {
    487:         $key = LangPeer::getPrimaryKeyHashFromRow($row, $startcol);
    488:         if (null !== ($obj = LangPeer::getInstanceFromPool($key))) {
    489:             // We no longer rehydrate the object, since this can cause data loss.
    490:             // See http://www.propelorm.org/ticket/509
    491:             // $obj->hydrate($row, $startcol, true); // rehydrate
    492:             $col = $startcol + LangPeer::NUM_HYDRATE_COLUMNS;
    493:         } else {
    494:             $cls = LangPeer::OM_CLASS;
    495:             $obj = new $cls();
    496:             $col = $obj->hydrate($row, $startcol);
    497:             LangPeer::addInstanceToPool($obj, $key);
    498:         }
    499:
    500:         return array($obj, $col);
    501:     }
    502:
    503:     /**
    504:      * Returns the TableMap related to this peer.
    505:      * This method is not needed for general use but a specific application could have a need.
    506:      * @return TableMap
    507:      * @throws PropelException Any exceptions caught during processing will be
    508:      *       rethrown wrapped into a PropelException.
    509:      */
    510:     public static function getTableMap()
    511:     {
    512:         return Propel::getDatabaseMap(LangPeer::DATABASE_NAME)->getTable(LangPeer::TABLE_NAME);
    513:     }
    514:
    515:     /**
    516:      * Add a TableMap instance to the database for this peer class.
    517:      */
    518:     public static function buildTableMap()
    519:     {
    520:       $dbMap = Propel::getDatabaseMap(BaseLangPeer::DATABASE_NAME);
    521:       if (!$dbMap->hasTable(BaseLangPeer::TABLE_NAME)) {
    522:         $dbMap->addTableObject(new LangTableMap());
    523:       }
    524:     }
    525:
    526:     /**
    527:      * The class that the Peer will make instances of.
    528:      *
    529:      *
    530:      * @return string ClassName
    531:      */
    532:     public static function getOMClass($row = 0, $colnum = 0)
    533:     {
    534:         return LangPeer::OM_CLASS;
    535:     }
    536:
    537:     /**
    538:      * Performs an INSERT on the database, given a Lang or Criteria object.
    539:      *
    540:      * @param      mixed $values Criteria or Lang object containing data that is used to create the INSERT statement.
    541:      * @param      PropelPDO $con the PropelPDO connection to use
    542:      * @return mixed           The new primary key.
    543:      * @throws PropelException Any exceptions caught during processing will be
    544:      *       rethrown wrapped into a PropelException.
    545:      */
    546:     public static function doInsert($values, PropelPDO $con = null)
    547:     {
    548:         if ($con === null) {
    549:             $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    550:         }
    551:
    552:         if ($values instanceof Criteria) {
    553:             $criteria = clone $values; // rename for clarity
    554:         } else {
    555:             $criteria = $values->buildCriteria(); // build Criteria from Lang object
    556:         }
    557:
    558:         if ($criteria->containsKey(LangPeer::ID) && $criteria->keyContainsValue(LangPeer::ID) ) {
    559:             throw new PropelException('Cannot insert a value for auto-increment primary key ('.LangPeer::ID.')');
    560:         }
    561:
    562:
    563:         // Set the correct dbName
    564:         $criteria->setDbName(LangPeer::DATABASE_NAME);
    565:
    566:         try {
    567:             // use transaction because $criteria could contain info
    568:             // for more than one table (I guess, conceivably)
    569:             $con->beginTransaction();
    570:             $pk = BasePeer::doInsert($criteria, $con);
    571:             $con->commit();
    572:         } catch (PropelException $e) {
    573:             $con->rollBack();
    574:             throw $e;
    575:         }
    576:
    577:         return $pk;
    578:     }
    579:
    580:     /**
    581:      * Performs an UPDATE on the database, given a Lang or Criteria object.
    582:      *
    583:      * @param      mixed $values Criteria or Lang object containing data that is used to create the UPDATE statement.
    584:      * @param      PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
    585:      * @return int             The number of affected rows (if supported by underlying database driver).
    586:      * @throws PropelException Any exceptions caught during processing will be
    587:      *       rethrown wrapped into a PropelException.
    588:      */
    589:     public static function doUpdate($values, PropelPDO $con = null)
    590:     {
    591:         if ($con === null) {
    592:             $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    593:         }
    594:
    595:         $selectCriteria = new Criteria(LangPeer::DATABASE_NAME);
    596:
    597:         if ($values instanceof Criteria) {
    598:             $criteria = clone $values; // rename for clarity
    599:
    600:             $comparison = $criteria->getComparison(LangPeer::ID);
    601:             $value = $criteria->remove(LangPeer::ID);
    602:             if ($value) {
    603:                 $selectCriteria->add(LangPeer::ID, $value, $comparison);
    604:             } else {
    605:                 $selectCriteria->setPrimaryTableName(LangPeer::TABLE_NAME);
    606:             }
    607:
    608:         } else { // $values is Lang object
    609:             $criteria = $values->buildCriteria(); // gets full criteria
    610:             $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
    611:         }
    612:
    613:         // set the correct dbName
    614:         $criteria->setDbName(LangPeer::DATABASE_NAME);
    615:
    616:         return BasePeer::doUpdate($selectCriteria, $criteria, $con);
    617:     }
    618:
    619:     /**
    620:      * Deletes all rows from the lang table.
    621:      *
    622:      * @param      PropelPDO $con the connection to use
    623:      * @return int             The number of affected rows (if supported by underlying database driver).
    624:      * @throws PropelException
    625:      */
    626:     public static function doDeleteAll(PropelPDO $con = null)
    627:     {
    628:         if ($con === null) {
    629:             $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    630:         }
    631:         $affectedRows = 0; // initialize var to track total num of affected rows
    632:         try {
    633:             // use transaction because $criteria could contain info
    634:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    635:             $con->beginTransaction();
    636:             $affectedRows += BasePeer::doDeleteAll(LangPeer::TABLE_NAME, $con, LangPeer::DATABASE_NAME);
    637:             // Because this db requires some delete cascade/set null emulation, we have to
    638:             // clear the cached instance *after* the emulation has happened (since
    639:             // instances get re-added by the select statement contained therein).
    640:             LangPeer::clearInstancePool();
    641:             LangPeer::clearRelatedInstancePool();
    642:             $con->commit();
    643:
    644:             return $affectedRows;
    645:         } catch (PropelException $e) {
    646:             $con->rollBack();
    647:             throw $e;
    648:         }
    649:     }
    650:
    651:     /**
    652:      * Performs a DELETE on the database, given a Lang or Criteria object OR a primary key value.
    653:      *
    654:      * @param      mixed $values Criteria or Lang object or primary key or array of primary keys
    655:      *              which is used to create the DELETE statement
    656:      * @param      PropelPDO $con the connection to use
    657:      * @return int The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
    658:      *              if supported by native driver or if emulated using Propel.
    659:      * @throws PropelException Any exceptions caught during processing will be
    660:      *       rethrown wrapped into a PropelException.
    661:      */
    662:      public static function doDelete($values, PropelPDO $con = null)
    663:      {
    664:         if ($con === null) {
    665:             $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
    666:         }
    667:
    668:         if ($values instanceof Criteria) {
    669:             // invalidate the cache for all objects of this type, since we have no
    670:             // way of knowing (without running a query) what objects should be invalidated
    671:             // from the cache based on this Criteria.
    672:             LangPeer::clearInstancePool();
    673:             // rename for clarity
    674:             $criteria = clone $values;
    675:         } elseif ($values instanceof Lang) { // it's a model object
    676:             // invalidate the cache for this single object
    677:             LangPeer::removeInstanceFromPool($values);
    678:             // create criteria based on pk values
    679:             $criteria = $values->buildPkeyCriteria();
    680:         } else { // it's a primary key, or an array of pks
    681:             $criteria = new Criteria(LangPeer::DATABASE_NAME);
    682:             $criteria->add(LangPeer::ID, (array) $values, Criteria::IN);
    683:             // invalidate the cache for this object(s)
    684:             foreach ((array) $values as $singleval) {
    685:                 LangPeer::removeInstanceFromPool($singleval);
    686:             }
    687:         }
    688:
    689:         // Set the correct dbName
    690:         $criteria->setDbName(LangPeer::DATABASE_NAME);
    691:
    692:         $affectedRows = 0; // initialize var to track total num of affected rows
    693:
    694:         try {
    695:             // use transaction because $criteria could contain info
    696:             // for more than one table or we could emulating ON DELETE CASCADE, etc.
    697:             $con->beginTransaction();
    698:
    699:             $affectedRows += BasePeer::doDelete($criteria, $con);
    700:             LangPeer::clearRelatedInstancePool();
    701:             $con->commit();
    702:
    703:             return $affectedRows;
    704:         } catch (PropelException $e) {
    705:             $con->rollBack();
    706:             throw $e;
    707:         }
    708:     }
    709:
    710:     /**
    711:      * Validates all modified columns of given Lang object.
    712:      * If parameter $columns is either a single column name or an array of column names
    713:      * than only those columns are validated.
    714:      *
    715:      * NOTICE: This does not apply to primary or foreign keys for now.
    716:      *
    717:      * @param      Lang $obj The object to validate.
    718:      * @param      mixed $cols Column name or array of column names.
    719:      *
    720:      * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
    721:      */
    722:     public static function doValidate($obj, $cols = null)
    723:     {
    724:         $columns = array();
    725:
    726:         if ($cols) {
    727:             $dbMap = Propel::getDatabaseMap(LangPeer::DATABASE_NAME);
    728:             $tableMap = $dbMap->getTable(LangPeer::TABLE_NAME);
    729:
    730:             if (! is_array($cols)) {
    731:                 $cols = array($cols);
    732:             }
    733:
    734:             foreach ($cols as $colName) {
    735:                 if ($tableMap->hasColumn($colName)) {
    736:                     $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
    737:                     $columns[$colName] = $obj->$get();
    738:                 }
    739:             }
    740:         } else {
    741:
    742:         }
    743:
    744:         return BasePeer::doValidate(LangPeer::DATABASE_NAME, LangPeer::TABLE_NAME, $columns);
    745:     }
    746:
    747:     /**
    748:      * Retrieve a single object by pkey.
    749:      *
    750:      * @param      int $pk the primary key.
    751:      * @param      PropelPDO $con the connection to use
    752:      * @return Lang
    753:      */
    754:     public static function retrieveByPK($pk, PropelPDO $con = null)
    755:     {
    756:
    757:         if (null !== ($obj = LangPeer::getInstanceFromPool((string) $pk))) {
    758:             return $obj;
    759:         }
    760:
    761:         if ($con === null) {
    762:             $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    763:         }
    764:
    765:         $criteria = new Criteria(LangPeer::DATABASE_NAME);
    766:         $criteria->add(LangPeer::ID, $pk);
    767:
    768:         $v = LangPeer::doSelect($criteria, $con);
    769:
    770:         return !empty($v) > 0 ? $v[0] : null;
    771:     }
    772:
    773:     /**
    774:      * Retrieve multiple objects by pkey.
    775:      *
    776:      * @param      array $pks List of primary keys
    777:      * @param      PropelPDO $con the connection to use
    778:      * @return Lang[]
    779:      * @throws PropelException Any exceptions caught during processing will be
    780:      *       rethrown wrapped into a PropelException.
    781:      */
    782:     public static function retrieveByPKs($pks, PropelPDO $con = null)
    783:     {
    784:         if ($con === null) {
    785:             $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ);
    786:         }
    787:
    788:         $objs = null;
    789:         if (empty($pks)) {
    790:             $objs = array();
    791:         } else {
    792:             $criteria = new Criteria(LangPeer::DATABASE_NAME);
    793:             $criteria->add(LangPeer::ID, $pks, Criteria::IN);
    794:             $objs = LangPeer::doSelect($criteria, $con);
    795:         }
    796:
    797:         return $objs;
    798:     }
    799:
    800: } // BaseLangPeer
    801:
    802: // This is the static code needed to register the TableMap for this table with the main Propel class.
    803: //
    804: BaseLangPeer::buildTableMap();
    805:
    806: