當前位置: 首頁>>代碼示例>>PHP>>正文


PHP eZPersistentObject::conditionTextByRow方法代碼示例

本文整理匯總了PHP中eZPersistentObject::conditionTextByRow方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZPersistentObject::conditionTextByRow方法的具體用法?PHP eZPersistentObject::conditionTextByRow怎麽用?PHP eZPersistentObject::conditionTextByRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eZPersistentObject的用法示例。


在下文中一共展示了eZPersistentObject::conditionTextByRow方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: reorderObject

 /**
  * Moves a row in a database table.
  *
  * Uses $orderField to determine the order of objects in a table, usually this
  * is a placement of some kind. It uses this order field to figure out how move
  * the row, the row is either swapped with another row which is either above or
  * below according to whether $down is true or false, or it is swapped
  * with the first item or the last item depending on whether this row
  * is first or last.
  * Uses $conditions to figure out unique rows.
  *
  * Note: Transaction unsafe. If you call several transaction unsafe methods
  * you must enclose the calls within a db transaction; thus within db->begin
  * and db->commit.
  *
  * @param array $def A definition array of all fields, table name and sorting (see {@link eZPersistentObject::definition()} for more info)
  * @param array $orderField Associative array with one element, the key is the order id and values is order value.
  * @param array $conditions
  * @param bool $down
  * @return void
  */
 public static function reorderObject($def, $orderField, $conditions, $down = true)
 {
     $db = eZDB::instance();
     $table = $def["name"];
     $keys = $def["keys"];
     reset($orderField);
     $order_id = key($orderField);
     $order_val = $orderField[$order_id];
     if ($down) {
         $order_operator = ">=";
         $order_type = "asc";
         $order_add = -1;
     } else {
         $order_operator = "<=";
         $order_type = "desc";
         $order_add = 1;
     }
     $fields = array_merge($keys, array($order_id));
     $rows = eZPersistentObject::fetchObjectList($def, $fields, array_merge($conditions, array($order_id => array($order_operator, $order_val))), array($order_id => $order_type), array("length" => 2), false);
     if (count($rows) == 2) {
         $swapSQL1 = eZPersistentObject::swapRow($table, $keys, $order_id, $rows, 1, 0);
         $swapSQL2 = eZPersistentObject::swapRow($table, $keys, $order_id, $rows, 0, 1);
         $db->begin();
         $db->query($swapSQL1);
         $db->query($swapSQL2);
         $db->commit();
     } else {
         $tmp = eZPersistentObject::fetchObjectList($def, $fields, $conditions, array($order_id => $order_type), array("length" => 1), false);
         $where_text = eZPersistentObject::conditionTextByRow($keys, $rows[0]);
         $db->query("UPDATE {$table} SET {$order_id}='" . ($tmp[0][$order_id] + $order_add) . "'{$where_text}");
     }
 }
開發者ID:mugoweb,項目名稱:ezpublish-legacy,代碼行數:53,代碼來源:ezpersistentobject.php


注:本文中的eZPersistentObject::conditionTextByRow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。