本文整理汇总了PHP中ActiveRecord::getDBConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::getDBConnection方法的具体用法?PHP ActiveRecord::getDBConnection怎么用?PHP ActiveRecord::getDBConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecord
的用法示例。
在下文中一共展示了ActiveRecord::getDBConnection方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($name = null)
{
parent::__construct($name);
if (class_exists('ActiveRecord')) {
$this->db = ActiveRecord::getDBConnection();
ActiveRecordModel::beginTransaction();
}
$app = ActiveRecordModel::getApplication();
$this->originalRequest = clone $app->getRequest();
$this->config = $app->getConfig();
$app->getConfigContainer()->disableModules();
}
示例2: setDatabase
public function setDatabase()
{
set_time_limit(0);
if (!$this->buildDatabaseValidator()->isValid()) {
return new ActionRedirectResponse('install', 'database');
}
$type = function_exists('mysql_connect') ? 'mysql' : 'mysqli';
$dsn = $type . '://' . $this->request->get('username') . ($this->request->get('password') ? ':' . $this->request->get('password') : '') . '@' . $this->request->get('server') . '/' . $this->request->get('name');
ClassLoader::import('library.activerecord.ActiveRecord');
ActiveRecord::resetDBConnection();
ActiveRecord::setDSN($dsn);
try {
$conn = ActiveRecord::getDBConnection();
// test if InnoDB tables can be created
$table = 'TestInnoDB';
$create = 'CREATE TABLE ' . $table . ' (ID INTEGER) ENGINE = INNODB';
$drop = 'DROP TABLE ' . $table;
ActiveRecord::executeUpdate($create);
$data = ActiveRecord::getDataBySQL('SHOW TABLE STATUS');
ActiveRecord::executeUpdate($drop);
foreach ($data as $row) {
if (strtolower($row['Name']) == strtolower($table)) {
if (strtolower($row['Engine']) != 'innodb') {
throw new SQLException('', $this->translate('_err_innodb_not_available'));
}
}
}
$dsnFile = $this->getDsnFile();
if (!file_exists(dirname($dsnFile))) {
mkdir(dirname($dsnFile), 0777, true);
}
ActiveRecord::beginTransaction();
//ActiveRecord::executeUpdate('SET FOREIGN_KEY_CHECKS = 0');
//ActiveRecord::executeUpdate('DROP TABLE `AccessControlAssociation`, `AdAdvertiser`, `AdAdvertiserUser`, `AdBanner`, `AdBannerStats`, `AdCampaign`, `AdCampaignCondition`, `AdZone`, `Author`, `AuthorImage`, `BillingAddress`, `Category`, `CategoryImage`, `CategoryPresentation`, `CategorySubscribeCategory`, `CategorySubscribeQueue`, `CategorySubscribeUser`, `Currency`, `CustomerOrder`, `DeliveryZone`, `DeliveryZoneAddressMask`, `DeliveryZoneCityMask`, `DeliveryZoneCountry`, `DeliveryZoneRealTimeService`, `DeliveryZoneState`, `DeliveryZoneWarehouse`, `DeliveryZoneZipMask`, `Discount`, `DiscountAction`, `DiscountCondition`, `DiscountConditionRecord`, `EavDateValue`, `EavField`, `EavFieldGroup`, `EavItem`, `EavNumericValue`, `EavObject`, `EavStringValue`, `EavValue`, `ExpressCheckout`, `Filter`, `FilterGroup`, `HelpComment`, `Language`, `Manufacturer`, `ManufacturerImage`, `NewsletterMessage`, `NewsletterSentMessage`, `NewsletterSubscriber`, `NewsPost`, `OrderCoupon`, `OrderDiscount`, `OrderedItem`, `OrderedItemOption`, `OrderLog`, `OrderNote`, `PostalCode`, `Product`, `ProductBundle`, `ProductCategory`, `ProductFile`, `ProductFileGroup`, `ProductImage`, `ProductList`, `ProductListItem`, `ProductOption`, `ProductOptionChoice`, `ProductPrice`, `ProductRating`, `ProductRatingSummary`, `ProductRatingType`, `ProductRelationship`, `ProductRelationshipGroup`, `ProductReview`, `ProductVariation`, `ProductVariationTemplate`, `ProductVariationType`, `ProductVariationValue`, `ProductWarehouse`, `PurchasePointsItemOrder`, `PurchasePointsOrder`, `PurchasePointsUser`, `RecurringProductPeriod`, `RewardPointsOrder`, `RewardPointsUser`, `Role`, `SearchLog`, `SessionData`, `Shipment`, `ShipmentTax`, `ShipmentWarehouse`, `ShippingAddress`, `ShippingRate`, `ShippingService`, `SpecField`, `SpecFieldGroup`, `SpecFieldValue`, `SpecificationDateValue`, `SpecificationItem`, `SpecificationNumericValue`, `SpecificationStringValue`, `State`, `StaticPage`, `Tax`, `TaxRate`, `Transaction`, `User`, `UserAddress`, `UserGroup`, `Warehouse`');
// import schema
Installer::loadDatabaseDump(file_get_contents(ClassLoader::getRealPath('installdata.sql') . '/create.sql'), true);
// create root category
Installer::loadDatabaseDump(file_get_contents(ClassLoader::getRealPath('installdata.sql') . '/initialData.sql'), true);
// states
Installer::loadDatabaseDump(file_get_contents(ClassLoader::getRealPath('installdata.sql.state') . '/all.sql'), true);
file_put_contents($dsnFile, '<?php return ' . var_export($dsn, true) . '; ?>');
ActiveRecord::commit();
return new ActionResponse();
//return new ActionRedirectResponse('install', 'admin');
} catch (SQLException $e) {
$validator = $this->buildDatabaseValidator();
$validator->triggerError('connect', $e->getNativeError());
$validator->saveState();
return new ActionResponse('step', 'database');
//return new ActionRedirectResponse('install', 'database');
}
}
示例3: executeQuery
private function executeQuery($db, $sql)
{
if (!$db) {
try {
$db = ActiveRecord::getDBConnection();
} catch (SQLException $e) {
throw $e;
}
}
if ($db) {
$db->query($sql);
ActiveRecord::commit();
}
}
示例4: getCountByManufacturers
public function getCountByManufacturers($includeAppliedFilters)
{
$selectFilter = $this->productFilter->getSelectFilter(!$includeAppliedFilters);
$selectFilter->removeFieldList();
$selectFilter->setLimit(0);
$selectFilter->setOrder(new ARExpressionHandle('cnt'), 'DESC');
$selectFilter->setGrouping(new ARFieldHandle('Product', 'manufacturerID'));
$selectFilter->mergeHavingCondition(new MoreThanCond(new ARExpressionHandle('cnt'), 0));
$selectFilter->mergeHavingCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), ''));
$selectFilter->resetOrder();
$selectFilter->setOrder(new ARFieldHandle('Manufacturer', 'name'));
$query = new ARSelectQueryBuilder();
$query->includeTable('Product');
$query->joinTable('Manufacturer', 'Product', 'ID', 'manufacturerID');
$query->joinTable('Category', 'Product', 'ID', 'categoryID');
$query->addField('COUNT(Product.manufacturerID)', null, 'cnt');
$query->addField('ID', 'Manufacturer');
$query->addField('name', 'Manufacturer');
$query->setFilter($selectFilter);
ActiveRecordModel::getApplication()->processInstancePlugins('manufacturerCountQuery', $query);
$data = ActiveRecordModel::getDataBySQL($query->getPreparedStatement(ActiveRecord::getDBConnection()));
return $data;
}
示例5: info
public function info()
{
ClassLoader::importNow("application.helper.getDateFromString");
$product = Product::getInstanceById($this->request->get('id'), ActiveRecord::LOAD_DATA, array('DefaultImage' => 'ProductImage', 'Manufacturer', 'Category'));
$thisMonth = date('m');
$lastMonth = date('Y-m', strtotime(date('m') . '/15 -1 month'));
$periods = array('_last_1_h' => "-1 hours | now", '_last_3_h' => "-3 hours | now", '_last_6_h' => "-6 hours | now", '_last_12_h' => "-12 hours | now", '_last_24_h' => "-24 hours | now", '_last_3_d' => "-3 days | now", '_this_week' => "w:Monday | now", '_last_week' => "w:Monday ~ -1 week | w:Monday", '_this_month' => $thisMonth . "/1 | now", '_last_month' => $lastMonth . "-1 | " . $lastMonth . "/1", '_this_year' => "January 1 | now", '_last_year' => "January 1 last year | January 1", '_overall' => "now | now");
$purchaseStats = array();
$prevCount = 0;
foreach ($periods as $key => $period) {
list($from, $to) = explode(' | ', $period);
$cond = new EqualsCond(new ARFieldHandle('OrderedItem', 'productID'), $product->getID());
if ('now' != $from) {
$cond->addAND(new EqualsOrMoreCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($from)));
}
if ('now' != $to) {
$cond->addAnd(new EqualsOrLessCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($to)));
}
$f = new ARSelectFilter($cond);
$f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true));
$f->removeFieldList();
$f->addField('SUM(OrderedItem.count)');
$query = new ARSelectQueryBuilder();
$query->setFilter($f);
$query->includeTable('OrderedItem');
$query->joinTable('CustomerOrder', 'OrderedItem', 'ID', 'customerOrderID');
if (($count = array_shift(array_shift(ActiveRecordModel::getDataBySql($query->getPreparedStatement(ActiveRecord::getDBConnection()))))) && ($count > $prevCount || '_overall' == $key)) {
$purchaseStats[$key] = $count;
}
if ($count > $prevCount) {
$prevCount = $count;
}
}
$response = new ActionResponse();
$response->set('together', $product->getProductsPurchasedTogether(10));
$response->set('product', $product->toArray());
$response->set('purchaseStats', $purchaseStats);
return $response;
}
示例6: getProductCount
public function getProductCount(ProductFilter $productFilter)
{
$query = new ARSelectQueryBuilder();
$query->includeTable('Product');
$query->addField('COUNT(*) AS cnt');
$filter = $this->getProductsFilter($productFilter);
$filter->setLimit(0);
$query->setFilter($filter);
$data = ActiveRecord::getDataBySQL($query->getPreparedStatement(ActiveRecord::getDBConnection()));
return $data[0]['cnt'];
}
示例7: getOrderArray
private function getOrderArray(ARSet $orders)
{
$orderArray = $orders->toArray();
$ids = array();
foreach ($orderArray as $key => $order) {
$ids[$order['ID']] = $key;
}
ClassLoader::import('application.model.order.OrderNote');
$f = new ARSelectFilter(new INCond(new ARFieldHandle('OrderNote', 'orderID'), empty($ids) ? array(-1) : array_keys($ids)));
$f->mergeCondition(new EqualsCond(new ARFieldHandle('OrderNote', 'isAdmin'), 1));
$f->mergeCondition(new EqualsCond(new ARFieldHandle('OrderNote', 'isRead'), 0));
$f->setGrouping(new ARFieldHandle('OrderNote', 'orderID'));
$query = new ARSelectQueryBuilder();
$query->setFilter($f);
$query->includeTable('OrderNote');
$query->removeFieldList();
$query->addField('COUNT(*)', null, 'cnt');
$query->addField('orderID');
foreach (ActiveRecordModel::getDataBySQL($query->getPreparedStatement(ActiveRecord::getDBConnection())) as $res) {
$orderArray[$ids[$res['orderID']]]['unreadMessageCount'] = $res['cnt'];
}
return $orderArray;
}
示例8: createFiltersInGroupsCountArray
private function createFiltersInGroupsCountArray(ARSet $filtersGroupsSet)
{
$filterGroupIds = array();
$filtersGroupsArray = array();
foreach ($filtersGroupsSet as $filterGroup) {
$filterGroupIds[] = $filterGroup->getID();
}
if (!empty($filterGroupIds)) {
$db = ActiveRecord::getDBConnection();
$filterGroupIdsString = implode(',', $filterGroupIds);
$filtersResultArray = array();
$filtersResultSet = $db->executeQuery("SELECT filterGroupID, COUNT(*) AS filtersCount FROM Filter WHERE filterGroupID IN ({$filterGroupIdsString}) GROUP BY filterGroupID");
while ($filtersResultSet->next()) {
$filtersResultArray[] = $filtersResultSet->getRow();
}
$filtersResultCount = count($filtersResultArray);
$specFieldValuesResultArray = array();
$specFieldValuesResultSet = $db->executeQuery("SELECT specFieldID, COUNT(specFieldID) AS filtersCount FROM SpecFieldValue WHERE specFieldID IN (SELECT specFieldID FROM FilterGroup WHERE ID in ({$filterGroupIdsString})) GROUP BY specFieldID");
while ($specFieldValuesResultSet->next()) {
$specFieldValuesResultArray[] = $specFieldValuesResultSet->getRow();
}
$specFieldValuesResultCount = count($specFieldValuesResultArray);
foreach ($filtersGroupsSet as $filterGroup) {
$filterGroupArray = $filterGroup->toArray();
$filterGroupArray['filtersCount'] = 0;
$field = $filterGroup->specField->get();
if ($field->isDate() || $field->isSimpleNumbers()) {
for ($i = 0; $i < $filtersResultCount; $i++) {
if ($filtersResultArray[$i]['filterGroupID'] == $filterGroupArray['ID']) {
$filterGroupArray['filtersCount'] = $filtersResultArray[$i]['filtersCount'];
}
}
} else {
for ($i = 0; $i < $specFieldValuesResultCount; $i++) {
if ($specFieldValuesResultArray[$i]['specFieldID'] == $filterGroupArray['SpecField']['ID']) {
$filterGroupArray['filtersCount'] = $specFieldValuesResultArray[$i]['filtersCount'];
}
}
}
$filtersGroupsArray[] = $filterGroupArray;
}
}
return $filtersGroupsArray;
}
示例9: set
/**
* @todo Rewrite this to use ARUpdateFilter or simply an SQL query to update all values
As in the original bug report:
The update query for merging value 799 into 808 would look something like this:
UPDATE SpecificationItem
LEFT JOIN SpecificationItem AS SecondItem ON SpecificationItem.productID=SecondItem.productID AND SecondItem.specFieldValueID=808
SET SpecificationItem.specFieldValueID=808
WHERE SpecificationItem.specFieldValueID=799 AND SecondItem.specFieldValueID IS NULL
- it would only update products that do not have value 808 already set (otherwise the query would error because of duplicate SpecificationItem records).
The remaining records with value 799 will be automatically removed (cascade) when SpecFieldValue 799 is deleted.
*/
private function mergeFields()
{
if (empty($this->mergedFields)) {
return true;
}
$itemClass = call_user_func(array($this->getFieldClass(), 'getSelectValueClass'));
$valueColumn = call_user_func(array($itemClass, 'getValueIDColumnName'));
$db = ActiveRecord::getDBConnection();
$specificationItemSchema = self::getSchemaInstance($itemClass);
$foreignKeys = $specificationItemSchema->getForeignKeyList();
$specFieldReferenceFieldName = '';
foreach ($foreignKeys as $foreignKey) {
if ($foreignKey->getForeignClassName() == get_class($this)) {
$specFieldReferenceFieldName = $foreignKey->getName();
break;
}
}
$thisSchema = self::getSchemaInstance(get_class($this));
$primaryKeyList = $thisSchema->getPrimaryKeyList();
$promaryKey = array_shift($primaryKeyList);
$mergedFieldsIDs = array();
foreach ($this->mergedFields as $mergedField) {
$mergedFieldsIDs[] = $mergedField->getID();
}
$inAllItemsExceptThisCondition = new INCond(new ARFieldHandle(get_class($this), $promaryKey->getName()), $mergedFieldsIDs);
$mergedFieldsIDs[] = $this->getID();
$inAllItemsCondition = new INCond(new ARFieldHandle($itemClass, $specFieldReferenceFieldName), $mergedFieldsIDs);
// Create filters
$mergedSpecificationItemsFilter = new ARSelectFilter();
$mergedSpecificationItemsFilter->setCondition($inAllItemsCondition);
// Using IGNORE I'm ignoring duplicate primary keys. Those rows that violate the uniqueness of the primary key are simply not saved
// Then later I just delete these records and the merge is complete.
$sql = 'UPDATE IGNORE ' . $itemClass . ' SET ' . $valueColumn . ' = ' . $this->getID() . ' ' . $mergedSpecificationItemsFilter->createString();
self::getLogger()->logQuery($sql);
$db->executeUpdate($sql);
$mergedSpecFieldValuesDeleteFilter = new ARDeleteFilter();
$mergedSpecFieldValuesDeleteFilter->setCondition($inAllItemsExceptThisCondition);
ActiveRecord::deleteRecordSet(get_class($this), $mergedSpecFieldValuesDeleteFilter);
}
示例10: getSubcategoriesBySearchQuery
/**
* Narrow search results by categories
*/
private function getSubcategoriesBySearchQuery(ARSelectFilter $selectFilter, $subCategories)
{
if (count($subCategories) > 0) {
$case = new ARCaseHandle();
$index = array();
foreach ($subCategories as $key => $cat) {
if (Category::ROOT_ID == $cat['ID']) {
continue;
}
$cond = new EqualsOrMoreCond(new ARFieldHandle('Category', 'lft'), $cat['lft']);
$cond->addAND(new EqualsOrLessCond(new ARFieldHandle('Category', 'rgt'), $cat['rgt']));
$case->addCondition($cond, new ARExpressionHandle($cat['ID']));
$index[$cat['ID']] = $key;
}
$query = new ARSelectQueryBuilder();
$query->includeTable('Product');
$filter = clone $selectFilter;
$filter->setLimit(0);
$filter->resetOrder();
$filter->setOrder(new ARExpressionHandle('cnt'), 'DESC');
$filter->setGrouping(new ARExpressionHandle('ID'));
foreach ($this->filters as $f) {
$f->defineJoin($filter);
}
$query->setFilter($filter);
$query->addField($case->toString(), null, 'ID');
$query->addField('COUNT(*)', null, 'cnt');
$query->joinTable('Category', 'Product', 'ID', 'categoryID');
$query->joinTable('ProductPrice', 'Product', 'productID AND (ProductPrice.currencyID = "' . $this->application->getDefaultCurrencyCode() . '")', 'ID');
$count = $query->getPreparedStatement(ActiveRecord::getDBConnection())->executeQuery();
$categoryNarrow = array();
foreach ($count as $cat) {
if (!isset($index[$cat['ID']])) {
continue;
}
$data = $subCategories[$index[$cat['ID']]];
$data['searchCount'] = $cat['cnt'];
$categoryNarrow[] = $data;
}
return $categoryNarrow;
}
}
示例11: moveTo
/**
* @param ActiveTreeNode $parentNode
* @param ActiveTreeNode $beforeNode=null If specified place node before this node, if not specified place last in parent nodes childs list
* @return bool
*
* @throws Exception If failed to commit the transaction
*/
public function moveTo(ActiveTreeNode $parentNode, ActiveTreeNode $beforeNode = null)
{
if (!$this->isLoaded()) {
$this->load();
}
$className = get_class($this);
$db = ActiveRecord::getDBConnection();
try {
if (!$parentNode->isLoaded()) {
$parentNode->load();
}
$t_r = $this->getFieldValue(self::RIGHT_NODE_FIELD_NAME);
$t_l = $this->getFieldValue(self::LEFT_NODE_FIELD_NAME);
$p_r = $parentNode->getFieldValue(self::RIGHT_NODE_FIELD_NAME);
$p_l = $parentNode->getFieldValue(self::LEFT_NODE_FIELD_NAME);
$width = $this->getWidth();
$s = 0;
$offset = 0;
$s2 = 0;
if ($beforeNode) {
if (!$beforeNode->isLoaded) {
$beforeNode->load();
}
$offset = $p_r - $beforeNode->getFieldValue(self::LEFT_NODE_FIELD_NAME);
$b_r = $beforeNode->getFieldValue(self::RIGHT_NODE_FIELD_NAME);
$b_l = $beforeNode->getFieldValue(self::LEFT_NODE_FIELD_NAME);
$s = $t_l > $b_r ? 0 : -1;
} else {
if ($this->getFieldValue(self::PARENT_NODE_FIELD_NAME)->getID() == $parentNode->getID()) {
$s = -1;
} else {
if (!($t_l > $p_l && $t_r < $p_r)) {
if ($p_l > $t_r) {
$s = -1;
} else {
$s2 = $width;
$s = 1;
}
} else {
$s = -1;
}
}
}
$leftPosition = $p_r - $offset + $s * $width - $s2;
$moveDistance = $t_l - $leftPosition;
// Step #1: Change target node left and right values to negotive
$updates[] = "UPDATE {$className} SET " . self::LEFT_NODE_FIELD_NAME . "=-" . self::LEFT_NODE_FIELD_NAME . ", " . self::RIGHT_NODE_FIELD_NAME . "=-" . self::RIGHT_NODE_FIELD_NAME . " WHERE " . self::LEFT_NODE_FIELD_NAME . " BETWEEN {$t_l} AND {$t_r}";
// Step #2: Now then there is no target node decrement all left and right values after target node position
$updates[] = "UPDATE {$className} SET " . self::RIGHT_NODE_FIELD_NAME . " = " . self::RIGHT_NODE_FIELD_NAME . " - {$width} WHERE " . self::RIGHT_NODE_FIELD_NAME . " > {$t_r}";
$updates[] = "UPDATE {$className} SET " . self::LEFT_NODE_FIELD_NAME . " = " . self::LEFT_NODE_FIELD_NAME . " - {$width} WHERE " . self::LEFT_NODE_FIELD_NAME . " > {$t_r}";
// Step #3: Make free space for new node to insert
$updates[] = "UPDATE {$className} SET " . self::RIGHT_NODE_FIELD_NAME . " = " . self::RIGHT_NODE_FIELD_NAME . " + {$width} WHERE " . self::RIGHT_NODE_FIELD_NAME . " >= " . $leftPosition;
$updates[] = "UPDATE {$className} SET " . self::LEFT_NODE_FIELD_NAME . " = " . self::LEFT_NODE_FIELD_NAME . " + {$width} WHERE " . self::LEFT_NODE_FIELD_NAME . " >= " . $leftPosition;
// Step #4: Change target node left and right values back to positive and put them to their place
$updates[] = "UPDATE {$className} SET " . self::LEFT_NODE_FIELD_NAME . "=-" . self::LEFT_NODE_FIELD_NAME . "-({$moveDistance}), " . self::RIGHT_NODE_FIELD_NAME . "=-" . self::RIGHT_NODE_FIELD_NAME . "-({$moveDistance}) WHERE " . self::LEFT_NODE_FIELD_NAME . " < 0";
# Step #1: Update parentNodeID
$this->setParentNode($parentNode);
$this->save();
foreach ($updates as $update) {
self::getLogger()->logQuery($update);
$db->executeUpdate($update);
}
$activeTreeNodes = ActiveRecord::retrieveFromPool(get_class($this));
foreach ($activeTreeNodes as $instance) {
if ($instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) >= $t_l && $instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) <= $t_r) {
$instance->setFieldValue(self::LEFT_NODE_FIELD_NAME, -$instance->getFieldValue(self::LEFT_NODE_FIELD_NAME));
$instance->setFieldValue(self::RIGHT_NODE_FIELD_NAME, -$instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME));
}
if ($instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) >= $t_r) {
$instance->setFieldValue(self::RIGHT_NODE_FIELD_NAME, $instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) - $width);
}
if ($instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) >= $t_r) {
$instance->setFieldValue(self::LEFT_NODE_FIELD_NAME, $instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) - $width);
}
if ($instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) >= $leftPosition) {
$instance->setFieldValue(self::RIGHT_NODE_FIELD_NAME, $instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) + $width);
}
if ($instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) >= $leftPosition) {
$instance->setFieldValue(self::LEFT_NODE_FIELD_NAME, $instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) + $width);
}
if ($instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) < 0) {
$instance->setFieldValue(self::LEFT_NODE_FIELD_NAME, -$instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) - $moveDistance);
$instance->setFieldValue(self::RIGHT_NODE_FIELD_NAME, -$instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) - $moveDistance);
}
}
} catch (Exception $e) {
ActiveRecordModel::rollback();
throw $e;
}
return true;
}