当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseFactory::getElementTableName方法代码示例

本文整理汇总了PHP中DatabaseFactory::getElementTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseFactory::getElementTableName方法的具体用法?PHP DatabaseFactory::getElementTableName怎么用?PHP DatabaseFactory::getElementTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatabaseFactory的用法示例。


在下文中一共展示了DatabaseFactory::getElementTableName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteElementList

 /**
  * Deletes an element list in database
  * @param string $elementClass The element class to delete
  * @param string $conditions The delete request conditions
  * @return int The affected rows number
  */
 public static function deleteElementList($elementClass, $conditions = null)
 {
     $tableName = DatabaseFactory::getElementTableName($elementClass);
     // Gets database connection instance
     $databaseConnection = $elementClass::getDatabaseConnection();
     // Builds request string
     $request = 'DELETE FROM ' . $tableName;
     if ($conditions !== NULL) {
         $request .= ' WHERE (' . $conditions . ')';
     }
     // Executes request in database
     $affectedRowNumber = $databaseConnection->deleteRequest($request);
     return $affectedRowNumber;
 }
开发者ID:jonathan-vallet,项目名称:craftanat,代码行数:20,代码来源:DatabaseFactory.class.php

示例2: setProperty

 /**
  * Property writing accessor
  * @param string $propertyName The property name
  * @param string $value The property value
  */
 public function setProperty($propertyName, $value)
 {
     // Non-null value
     if ($value !== NULL) {
         // Numeric value
         if (StringTool::isInt($value)) {
             $value = StringTool::toInt($value, false);
         } else {
             if (StringTool::isFloat($value, FALSE)) {
                 $value = StringTool::toFloat($value, false);
             } else {
                 if (StringTool::endsWith($propertyName, 'date')) {
                     // Date has a 10 length (YYYY-mm-dd)
                     if (StringTool::strlen($value) == 10) {
                         $value = DateTool::stringToTimestamp($value, DateTool::FORMAT_MYSQL_DATE);
                     } else {
                         $value = DateTool::stringToTimestamp($value);
                     }
                 }
             }
         }
         // Day property type
     }
     // Removes table name at the beginning of field name, not for id fields nor xxx_has_xxx tables
     $tableName = DatabaseFactory::getElementTableName($this->getElementClass());
     if (!StringTool::contains($tableName, ElementFactory::TABLE_JOIN_SEPARATOR)) {
         $tablePrefix = $tableName . '_';
         $tableIdField = $tablePrefix . 'id';
         if (StringTool::startsWith($propertyName, $tablePrefix) && (!StringTool::endsWith($propertyName, '_id') || $propertyName == $tableIdField)) {
             $propertyName = StringTool::truncateFirstChars($propertyName, StringTool::strlen($tablePrefix));
         }
     }
     // Updates original property list
     if (!ArrayTool::array_key_exists($propertyName, $this->propertyList)) {
         // It's the first time this property gets a value, it will be updated (set a null value to original property list)
         $this->originalPropertyList[$propertyName] = NULL;
     } else {
         if (ArrayTool::array_key_exists($propertyName, $this->originalPropertyList)) {
             // Attribute value had already changed (originalPropertyList already has a value for this property)
             // If value has been reset to original value, removes the update of the property
             if ($value == $this->originalPropertyList[$propertyName]) {
                 unset($this->originalPropertyList[$propertyName]);
             }
         } else {
             if ($value !== $this->propertyList[$propertyName]) {
                 // If value has changed, updates original value
                 $this->originalPropertyList[$propertyName] = $this->propertyList[$propertyName];
             }
         }
     }
     // Sets property new value
     $this->propertyList[$propertyName] = $value;
 }
开发者ID:jonathan-vallet,项目名称:craftanat,代码行数:58,代码来源:Element.class.php

示例3: AND

 /**
  * Gets element list link to an element
  * @param string $elementClass The element class searched
  * @param string $parentElement The parent element to get list of
  * @param string $conditions The conditions string to apply
  * @param string $orderBy The order string to apply)
  * @return array The element list array
  */
 public static function &getElementListFromParent($elementClass, $parentElement, $conditions = NULL, $orderBy = NULL, $join = NULL)
 {
     $parentClass = $parentElement->getElementClass();
     $parentId = $parentElement->id;
     // Builds parent id conditions
     $parentIdFieldName = DatabaseFactory::getParentIdColumnName($parentClass);
     $tableName = DatabaseFactory::getElementTableName($elementClass);
     $parentIdCondition = $tableName . '.' . $parentIdFieldName . '=' . $parentId;
     if ($conditions !== NULL && StringTool::strlen($conditions) > 0) {
         $conditions = $parentIdCondition . ' AND (' . $conditions . ')';
     } else {
         $conditions = $parentIdCondition;
     }
     $elementList = ElementFactory::getElementList($elementClass, $conditions, $orderBy, $join);
     return $elementList;
 }
开发者ID:jonathan-vallet,项目名称:craftanat,代码行数:24,代码来源:ElementFactory.class.php


注:本文中的DatabaseFactory::getElementTableName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。