コード例 #1
0
ファイル: LanguageQuery.php プロジェクト: keeko/core
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     ConnectionInterface $con A connection object
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildLanguage A model object, or null if the key is not found
  */
 protected function findPkSimple($key, ConnectionInterface $con)
 {
     $sql = 'SELECT `id`, `alpha_2`, `alpha_3T`, `alpha_3B`, `alpha_3`, `parent_id`, `macrolanguage_status`, `name`, `native_name`, `collate`, `subtag`, `prefix`, `scope_id`, `type_id`, `family_id`, `default_script_id` FROM `kk_language` WHERE `id` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
         /** @var ChildLanguage $obj */
         $obj = new ChildLanguage();
         $obj->hydrate($row);
         LanguageTableMap::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
コード例 #2
0
ファイル: Language.php プロジェクト: keeko/core
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME,
  *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  *                    Defaults to TableMap::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['Language'][$this->hashCode()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Language'][$this->hashCode()] = true;
     $keys = LanguageTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAlpha2(), $keys[2] => $this->getAlpha3T(), $keys[3] => $this->getAlpha3B(), $keys[4] => $this->getAlpha3(), $keys[5] => $this->getParentId(), $keys[6] => $this->getMacrolanguageStatus(), $keys[7] => $this->getName(), $keys[8] => $this->getNativeName(), $keys[9] => $this->getCollate(), $keys[10] => $this->getSubtag(), $keys[11] => $this->getPrefix(), $keys[12] => $this->getScopeId(), $keys[13] => $this->getTypeId(), $keys[14] => $this->getFamilyId(), $keys[15] => $this->getDefaultScriptId());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aParent) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'language';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'kk_language';
                     break;
                 default:
                     $key = 'Language';
             }
             $result[$key] = $this->aParent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aScope) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'languageScope';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'kk_language_scope';
                     break;
                 default:
                     $key = 'LanguageScope';
             }
             $result[$key] = $this->aScope->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aType) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'languageType';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'kk_language_type';
                     break;
                 default:
                     $key = 'LanguageType';
             }
             $result[$key] = $this->aType->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aScript) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'languageScript';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'kk_language_script';
                     break;
                 default:
                     $key = 'LanguageScript';
             }
             $result[$key] = $this->aScript->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aFamily) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'languageFamily';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'kk_language_family';
                     break;
                 default:
                     $key = 'LanguageFamily';
             }
             $result[$key] = $this->aFamily->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collSublanguages) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'languages';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'kk_languages';
                     break;
                 default:
                     $key = 'Languages';
             }
             $result[$key] = $this->collSublanguages->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collLocalizationsRelatedByLanguageId) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'localizations';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'kk_localizations';
                     break;
                 default:
                     $key = 'Localizations';
             }
             $result[$key] = $this->collLocalizationsRelatedByLanguageId->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collLocalizationsRelatedByExtLanguageId) {
             switch ($keyType) {
                 case TableMap::TYPE_CAMELNAME:
                     $key = 'localizations';
                     break;
                 case TableMap::TYPE_FIELDNAME:
                     $key = 'kk_localizations';
                     break;
                 default:
                     $key = 'Localizations';
             }
             $result[$key] = $this->collLocalizationsRelatedByExtLanguageId->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }
コード例 #3
0
ファイル: LanguageTableMap.php プロジェクト: keeko/core
 /**
  * Performs a DELETE on the database, given a Language or Criteria object OR a primary key value.
  *
  * @param mixed               $values Criteria or Language object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param  ConnectionInterface $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, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(LanguageTableMap::DATABASE_NAME);
     }
     if ($values instanceof Criteria) {
         // rename for clarity
         $criteria = $values;
     } elseif ($values instanceof \keeko\core\model\Language) {
         // it's a model object
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it's a primary key, or an array of pks
         $criteria = new Criteria(LanguageTableMap::DATABASE_NAME);
         $criteria->add(LanguageTableMap::COL_ID, (array) $values, Criteria::IN);
     }
     $query = LanguageQuery::create()->mergeWith($criteria);
     if ($values instanceof Criteria) {
         LanguageTableMap::clearInstancePool();
     } elseif (!is_object($values)) {
         // it's a primary key, or an array of pks
         foreach ((array) $values as $singleval) {
             LanguageTableMap::removeInstanceFromPool($singleval);
         }
     }
     return $query->delete($con);
 }