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


PHP RedBeanModel::makeModels方法代码示例

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


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

示例1: 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


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