<?php $a = $modx->getCollection('modResource', 3); $b = $modx->getCollection('modResource', 3); $obj = $a[3]; print ($a[3] === $obj ? 1: 0); // result 1 $obj = $b[3]; print ($a[3] === $obj ? 1: 0); // result 0
<?php print '<pre>'; $a = array( 2 => 'object' ); $b = array( 2 => 'new object', 5 => 'object', 7 => 'object', ) + $a; print_r($b);
Array ( [2] => new object [5] => object [7] => object )
<h1>Доступные номера</h1> <p style="padding-top:10px; font-weight:bold;"> Выберите понравившийся номер и необходимые дополнительные услуги </p> {processor ns=Hotel action="web/reservation/step/search/index" assign=result nocache} {if $result.success==true} <table cellspacing="0" cellpadding="0" border="0" id="room-types-cont" class="base-cont"> <thead><tr> <td class="cell left-holder"> </td> <td class="cell name">Категория номера</td> <td colspan="2" class="cell price"> Цена за <strong>1 ночь</strong>, <span class="currency">руб.</span></td> <td class="cell quantity">Количество номеров</td> <td class="cell amount right-cell">Стоимость, <span class="currency">руб.</span></td></tr> </thead> <tbody> {* All rooms *} {foreach from=$result.object key=room_id item=room nocache} {* counf variables *} {assign var=variables_total value=count($room.variables)} <tr> <td class="cell left-holder" rowspan="{$variables_total+2}"> </td> <td class="cell" rowspan="{$variables_total+2}"> <div class="title">{$room.room.title}</div> </td> <td class="cell empty-cell"> </td> <td class="cell empty-cell"> </td> <td class="cell empty-cell"> </td> <td class="cell empty-cell"> </td> </tr> {* All variables *} {foreach from=$room.variables key=variable_id item=variable} <tr> <td class="cell empty-cell"> </td> <td class="cell empty-cell"> </td> <td class="cell empty-cell"> </td> <td class="cell empty-cell"> </td> </tr> {/foreach} {* Eof All variables *} <tr class="room-type"> <td class="cell persons empty-cell border-top-0"> </td> <td class="cell price empty-cell border-top-0"> </td> <td class="cell quantity empty-cell border-top-0"> </td> <td class="cell amount empty-cell border-top-0"> </td> </tr> {/foreach} {* Eof All rooms *} </tbody> </table> {else} {$result.message} {/if}
{if $result.success==true}
{else} {$result.message} {/if}
{foreach from=$result.object key=room_id item=room nocache}
<td class="cell left-holder" rowspan="{$variables_total+2}">
{foreach from=$room.variables key=variable_id item=variable}
[[+var:notempty=`[[!mysnippet]]`]]
{if $var!=''} {snippet name=mysnippet} {/if}
<?php print '<pre>'; $a = array( 2=>'object' ); $b = $a + array( 2 => 'new object', 5 =>'object', 7 => 'object', ); print_r($b);
Array ( [2] => object [5] => object [7] => object )
Нет, так нельзя делать. Это ссумируем массивы, а нам надо заменять уже имеющиеся.
$a = array("a" => "apple", "b" => "banana"); $b = array("a" => "pear", "b" => "strawberry", "c" => "cherry"); $c = $b + $a; var_dump($c); // array(3) { // ["a"]=> // string(4) "pear" // ["b"]=> // string(10) "strawberry" // ["c"]=> // string(6) "cherry" // }
( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `item` int(10) unsigned NOT NULL, `datefrom` datetime NOT NULL, `datetill` datetime NOT NULL, PRIMARY KEY (`id`), KEY `item` (`item`,`datefrom`,`datetill`) )
<?php print '<pre>'; $datefrom = "2013-04-06 12:00:01"; $datetill = "2013-04-08 11:59:59"; $c = $modx->newQuery('HotelRoomItem'); $c->leftJoin('HotelRoomReserve', 'Reserves', "Reserves.item=HotelRoomItem.id AND ( (Reserves.datefrom between '{$datefrom}' AND '{$datetill}') OR (Reserves.datetill between '{$datefrom}' AND '{$datetill}') OR (Reserves.datefrom < '{$datefrom}' AND Reserves.datetill > '{$datetill}') )" ); $c->select(array( 'HotelRoomItem.id as item_id', 'Reserves.*', )); $where = array( 'HotelRoomItem.active' => 1, 'Reserves.id' => null, ); $c->where($where);
SELECT HotelRoomItem.id as item_id, Reserves.* FROM `modx_hotel_room_items` AS `HotelRoomItem` LEFT JOIN `modx_hotel_room_reserve` `Reserves` ON Reserves.item=HotelRoomItem.id AND ( (Reserves.datefrom between '2013-04-06 12:00:01' AND '2013-04-08 11:59:59') OR (Reserves.datetill between '2013-04-06 12:00:01' AND '2013-04-08 11:59:59') OR (Reserves.datefrom < '2013-04-06 12:00:01' AND Reserves.datetill > '2013-04-08 11:59:59') ) WHERE ( `HotelRoomItem`.`active` = 1 AND `Reserves`.`id` IS NULL )
$this->_relatedObjects[$alias]= $collection + $this->_relatedObjects[$alias];
а если не ошибаюсь, то нужен коммит, чтобы в 2.2.7 зарелизить успели
$this->_relatedObjects[$alias]= $collection + $this->_relatedObjects[$alias];