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


PHP RedBeanModel::getForeignKeyName方法代码示例

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


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

示例1: isCurrencyInUseById

 /**
  * Given an id of a currency model, determine if any currency values are using this currency.
  * @return true if at least one currency value model is using this currency.
  * @param integer $currencyId
  */
 public static function isCurrencyInUseById($currencyId)
 {
     assert('is_int($currencyId)');
     $columnName = RedBeanModel::getForeignKeyName('CurrencyValue', 'currency');
     $quote = DatabaseCompatibilityUtil::getQuote();
     $where = "{$quote}{$columnName}{$quote} = '{$currencyId}'";
     $count = CurrencyValue::getCount(null, $where);
     if ($count > 0) {
         return true;
     }
     return false;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:17,代码来源:CurrencyValue.php

示例2: updateValueByDataIdAndOldValueAndNewValue

 public static function updateValueByDataIdAndOldValueAndNewValue($customFieldDataId, $oldValue, $newValue)
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     $customFieldTableName = RedBeanModel::getTableName('CustomField');
     $baseCustomFieldTableName = RedBeanModel::getTableName('BaseCustomField');
     $baseCustomFieldJoinColumnName = $baseCustomFieldTableName . '_id';
     $valueAttributeColumnName = 'value';
     $dataAttributeColumnName = RedBeanModel::getForeignKeyName('BaseCustomField', 'data');
     $sql = "update {$quote}{$customFieldTableName}{$quote}, {$quote}{$baseCustomFieldTableName}{$quote} ";
     $sql .= "set {$quote}{$valueAttributeColumnName}{$quote} = '{$newValue}' ";
     $sql .= "where {$quote}{$customFieldTableName}{$quote}.{$baseCustomFieldJoinColumnName} = ";
     // Not Coding Standard
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id ";
     $sql .= "AND {$quote}{$dataAttributeColumnName}{$quote} = {$customFieldDataId} ";
     $sql .= "AND {$quote}{$valueAttributeColumnName}{$quote} = '{$oldValue}'";
     R::exec($sql);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:17,代码来源:CustomField.php

示例3: testUpdateValueOnCustomFieldRows

 /**
  * @depends testSetAttributesWithPostForCustomField
  */
 public function testUpdateValueOnCustomFieldRows()
 {
     $values = array('A', 'B', 'C');
     $customFieldData = CustomFieldData::getByName('updateItems');
     $customFieldData->serializedData = serialize($values);
     $this->assertTrue($customFieldData->save());
     $id = $customFieldData->id;
     $customField = new CustomField();
     $customField->value = 'A';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'B';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'C';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $customField = new CustomField();
     $customField->value = 'C';
     $customField->data = $customFieldData;
     $this->assertTrue($customField->save());
     $quote = DatabaseCompatibilityUtil::getQuote();
     $customFieldTableName = CustomField::getTableName();
     $baseCustomFieldTableName = BaseCustomField::getTableName();
     $valueAttributeColumnName = 'value';
     $dataAttributeColumnName = RedBeanModel::getForeignKeyName('CustomField', 'data');
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id}";
     $ids = ZurmoRedBean::getCol($sql);
     $beans = ZurmoRedBean::batch($customFieldTableName, $ids);
     $customFields = RedBeanModel::makeModels($beans, 'CustomField');
     $this->assertEquals(4, count($customFields));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'B'";
     $this->assertEquals(1, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'C'";
     $this->assertEquals(2, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'E'";
     $this->assertEquals(0, count(ZurmoRedBean::getCol($sql)));
     CustomField::updateValueByDataIdAndOldValueAndNewValue($id, 'C', 'E');
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'B'";
     $this->assertEquals(1, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'C'";
     $this->assertEquals(0, count(ZurmoRedBean::getCol($sql)));
     $sql = "select {$quote}{$customFieldTableName}{$quote}.id from {$quote}{$customFieldTableName}{$quote} ";
     $sql .= "left join {$quote}{$baseCustomFieldTableName}{$quote} on ";
     $sql .= "{$quote}{$baseCustomFieldTableName}{$quote}.id = ";
     $sql .= "{$quote}{$customFieldTableName}{$quote}.basecustomfield_id ";
     $sql .= "where {$quote}{$dataAttributeColumnName}{$quote} = {$id} ";
     $sql .= "and {$quote}{$valueAttributeColumnName}{$quote} = 'E'";
     $this->assertEquals(2, count(ZurmoRedBean::getCol($sql)));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:84,代码来源:CustomFieldTest.php

示例4: updateFolderForEmailMessageWithSQL

 /**
  * Update an email message's folder and save it using SQL
  * @param EmailMessage $emailMessage
  * @param EmailFolder $folder
  * @throws NotSupportedException
  */
 protected static function updateFolderForEmailMessageWithSQL(EmailMessage &$emailMessage, EmailFolder $folder)
 {
     // TODO: @Shoaibi/@Jason: Critical0: This fails CampaignItemsUtilTest.php:243
     $folderForeignKeyName = RedBeanModel::getForeignKeyName('EmailMessage', 'folder');
     $tableName = EmailMessage::getTableName();
     $sql = "UPDATE " . DatabaseCompatibilityUtil::quoteString($tableName);
     $sql .= " SET " . DatabaseCompatibilityUtil::quoteString($folderForeignKeyName);
     $sql .= " = " . $folder->id;
     $sql .= " WHERE " . DatabaseCompatibilityUtil::quoteString('id') . " = " . $emailMessage->id;
     $effectedRows = ZurmoRedBean::exec($sql);
     if ($effectedRows == 1) {
         $emailMessageId = $emailMessage->id;
         $emailMessage->forgetAll();
         $emailMessage = EmailMessage::getById($emailMessageId);
         return true;
     }
     return false;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:24,代码来源:EmailHelper.php

示例5: resolve

 /**
  * Generates a column definition or processes junctions table depending on relation and link type.
  * @param string $modelClassName
  * @param string $relationName
  * @param array $relationMetadata
  * @param $messageLogger
  * @return array|null
  */
 public static function resolve($modelClassName, $relationName, array $relationMetadata, &$messageLogger)
 {
     $column = null;
     if (!empty($modelClassName) && @class_exists($modelClassName) && !empty($relationName) && count($relationMetadata) >= 2 && @class_exists($relationMetadata[1])) {
         $relationType = $relationMetadata[0];
         $relatedModelClass = $relationMetadata[1];
         $linkType = RedBeanModel::LINK_TYPE_ASSUMPTIVE;
         if (isset($relationMetadata[3])) {
             $linkType = $relationMetadata[3];
         }
         if (!in_array($relationType, array(RedBeanModel::HAS_ONE_BELONGS_TO, RedBeanModel::HAS_MANY_BELONGS_TO, RedBeanModel::HAS_ONE, RedBeanModel::HAS_MANY, RedBeanModel::MANY_MANY))) {
             return false;
         }
         if ($relationType == RedBeanModel::MANY_MANY) {
             RedBeanModelToJoinTableAdapter::resolve($modelClassName, $relationMetadata, $messageLogger);
             return null;
         } elseif (in_array($relationType, array(RedBeanModel::HAS_ONE, RedBeanModel::HAS_MANY_BELONGS_TO))) {
             $linkName = null;
             if ($linkType == RedBeanModel::LINK_TYPE_ASSUMPTIVE && strtolower($relatedModelClass) != strtolower($relationName)) {
                 $linkName = strtolower($relationName) . '_';
             }
             $name = $linkName . RedBeanModel::getForeignKeyName($modelClassName, $relationName);
             $column = RedBeanModelMemberToColumnUtil::resolveForeignKeyColumnMetadata($name);
         } elseif ($relationType == RedBeanModel::HAS_MANY && $linkType == RedBeanModel::LINK_TYPE_POLYMORPHIC) {
             static::setColumnsForPolymorphicLink($relatedModelClass, $relationMetadata[4]);
         }
         // ignore HAS_MANY(non-polymorphic) and HAS_ONE_BELONGS_TO as we are dealing with HAS_ONE and HAS_MANY_BELONGS e.g.
         // we are ignore the sides which shouldn't have columns.
     } else {
         return false;
     }
     return $column;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:41,代码来源:RedBeanModelRelationToColumnAdapter.php

示例6: resolveReadPermissionsOptimizationToSqlQuery

 /**
  * @param User $user
  * @param RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter
  * @param $where
  * @param $selectDistinct
  * @throws NotSupportedException
  */
 public static function resolveReadPermissionsOptimizationToSqlQuery(User $user, RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter, &$where, &$selectDistinct)
 {
     assert('$where == null || is_string($where)');
     assert('is_bool($selectDistinct)');
     $modelClassName = get_called_class();
     $moduleClassName = $modelClassName::getModuleClassName();
     //Currently only adds munge if the module is securable and this model supports it.
     if (static::hasReadPermissionsOptimization() && $moduleClassName != null && is_subclass_of($moduleClassName, 'SecurableModule')) {
         $permission = PermissionsUtil::getActualPermissionDataForReadByModuleNameForCurrentUser($moduleClassName);
         if ($permission == Permission::NONE || $permission == Permission::DENY) {
             $quote = DatabaseCompatibilityUtil::getQuote();
             $modelAttributeToDataProviderAdapter = new OwnedSecurableItemIdToDataProviderAdapter($modelClassName, null);
             $builder = new ModelJoinBuilder($modelAttributeToDataProviderAdapter, $joinTablesAdapter);
             $ownedTableAliasName = $builder->resolveJoins();
             $ownerColumnName = RedBeanModel::getForeignKeyName('OwnedSecurableItem', 'owner');
             $mungeIds = ReadPermissionsOptimizationUtil::getMungeIdsByUser($user);
             if ($where != null) {
                 $where = '(' . $where . ') and ';
             }
             if (count($mungeIds) > 0 && $permission == Permission::NONE) {
                 $extraOnQueryPart = " and {$quote}munge_id{$quote} in ('" . join("', '", $mungeIds) . "')";
                 $mungeTableName = ReadPermissionsOptimizationUtil::getMungeTableName($modelClassName);
                 $mungeTableAliasName = $joinTablesAdapter->addLeftTableAndGetAliasName($mungeTableName, 'securableitem_id', $ownedTableAliasName, 'securableitem_id', $extraOnQueryPart);
                 $where .= "({$quote}{$ownedTableAliasName}{$quote}.{$quote}{$ownerColumnName}{$quote} = {$user->id} OR ";
                 // Not Coding Standard
                 $where .= "{$quote}{$mungeTableName}{$quote}.{$quote}munge_id{$quote} IS NOT NULL)";
                 // Not Coding Standard
                 $selectDistinct = true;
                 //must use distinct since adding munge table query.
             } elseif ($permission == Permission::DENY) {
                 $where .= "{$quote}{$ownedTableAliasName}{$quote}.{$quote}{$ownerColumnName}{$quote} = {$user->id}";
                 // Not Coding Standard
             } else {
                 throw new NotSupportedException();
             }
         }
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:45,代码来源:OwnedSecurableItem.php

示例7: testRedBeanModelGetForeignKeyNameBarfsForBadAttribute

 /**
  * @expectedException NotSupportedException
  */
 public function testRedBeanModelGetForeignKeyNameBarfsForBadAttribute()
 {
     RedBeanModel::getForeignKeyName('Account', 'massagedByUser');
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:7,代码来源:FilteredListDataProviderTest.php

示例8: getEmailMessageForeignKeyName

 protected function getEmailMessageForeignKeyName()
 {
     $itemClassName = $this->getItemClassName();
     return RedBeanModel::getForeignKeyName($itemClassName, 'emailMessage');
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:5,代码来源:AutoresponderOrCampaignBaseTest.php

示例9: markItemAsProcessedWithSQL

 protected function markItemAsProcessedWithSQL($emailMessageId = null)
 {
     $className = $this->itemClass;
     $itemTableName = $className::getTableName();
     $sql = "UPDATE " . DatabaseCompatibilityUtil::quoteString($itemTableName);
     $sql .= " SET " . DatabaseCompatibilityUtil::quoteString('processed') . ' = 1';
     if ($emailMessageId) {
         $emailMessageForeignKey = RedBeanModel::getForeignKeyName($this->itemClass, 'emailMessage');
         $sql .= ", " . DatabaseCompatibilityUtil::quoteString($emailMessageForeignKey);
         $sql .= " = {$emailMessageId}";
     }
     $sql .= " WHERE " . DatabaseCompatibilityUtil::quoteString('id') . " = {$this->itemId};";
     $effectedRows = ZurmoRedBean::exec($sql);
     return $effectedRows == 1;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:15,代码来源:AutoresponderAndCampaignItemsUtil.php


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