/** * Test the reorder method. * * @return void * * @since 12.3 */ public function testReorder() { $this->object->load(array('id1' => 25, 'id2' => 51)); $this->object->ordering = 25; $this->object->store(); $object2 = new TableDbTestComposite(TestCaseDatabase::$driver); $object2->load(array('id1' => 25, 'id2' => 51)); $this->assertEquals(25, $object2->ordering, 'Preconditions'); $this->object->reorder(); $object2->load(array('id1' => 25, 'id2' => 51)); $this->assertEquals(2, $object2->ordering, 'Elements did not get reordered'); }
function reorder($where = '') { parent::reorder('option_id = ' . $this->_db->Quote($this->option_id)); }
/** * Prepare and sanitise the table data prior to saving. * * @param JTable $table A JTable object. * * @return void * * @since 1.6 */ protected function prepareTable($table) { // Set the publish date to now $db = $this->getDbo(); if ($table->state == 1 && (int) $table->publish_up == 0) { $table->publish_up = JFactory::getDate()->toSql(); } if ($table->state == 1 && intval($table->publish_down) == 0) { $table->publish_down = $db->getNullDate(); } // Increment the content version number. $table->version++; // Reorder the articles within the category so the new article is first if (empty($table->id)) { $table->reorder('catid = ' . (int) $table->catid . ' AND state >= 0'); } }
/** * Method to set new item ordering as first or last. * * @param JTable $table Item table to save. * @param string $position 'first' or other are last. * * @return type */ public function setOrderPosition($table, $position = null) { if ($position == 'first') { if (!$table->ordering) { $table->reorder('catid = ' . (int) $table->catid . ' AND published >= 0'); } } else { // Set ordering to the last item if not set if (empty($table->ordering)) { $db = JFactory::getDbo(); $db->setQuery('SELECT MAX(ordering) FROM #__' . $this->component . '_' . $this->list_name); $max = $db->loadResult(); $table->ordering = $max + 1; } } }
function reorder() { parent::reorder('product_id = ' . $this->_db->Quote($this->product_id)); }
/** * Prepare and sanitise the table data prior to saving. * * @param JTable $table A JTable object. * * @return void * * @since 1.6 */ protected function prepareTable($table) { // Reorder the articles within the category so the new article is first if (empty($table->id)) { $table->reorder('enabled >= 1'); } }