API15

Difference between revisions of "JTable/move"

From Joomla! Documentation

< API15:JTable
(New page: ===Description=== Description <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Descripti...)
 
m (preparing for archive only)
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JTable/move|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JTable/move}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 116: Line 116:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JTable/move|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JTable/move}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
<CodeExamplesForm />
+
=== Code Examples ===
 
<dpl>
 
<dpl>
 
  noresultsheader=\n
 
  noresultsheader=\n
 
  category=move
 
  category=move
 
  category=JTable
 
  category=JTable
  category=CodeExample
+
  namespace=CodeExample
 
  category=MethodExample
 
  category=MethodExample
 
  include=*
 
  include=*
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Latest revision as of 20:10, 24 March 2017

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Description

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

move($dirn, $where='')
Parameter Name Default Value Description
$dirn
$where

Defined in[edit]

libraries/joomla/database/table.php

Importing[edit]

jimport( 'joomla.database.table' );

Source Body[edit]

function move( $dirn, $where='' )
{
        if (!in_array( 'ordering',  array_keys($this->getProperties())))
        {
                $this->setError( get_class( $this ).' does not support ordering' );
                return false;
        }

        $k = $this->_tbl_key;

        $sql = "SELECT $this->_tbl_key, ordering FROM $this->_tbl";

        if ($dirn < 0)
        {
                $sql .= ' WHERE ordering < '.(int) $this->ordering;
                $sql .= ($where ? ' AND '.$where : '');
                $sql .= ' ORDER BY ordering DESC';
        }
        else if ($dirn > 0)
        {
                $sql .= ' WHERE ordering > '.(int) $this->ordering;
                $sql .= ($where ? ' AND '. $where : '');
                $sql .= ' ORDER BY ordering';
        }
        else
        {
                $sql .= ' WHERE ordering = '.(int) $this->ordering;
                $sql .= ($where ? ' AND '.$where : '');
                $sql .= ' ORDER BY ordering';
        }

        $this->_db->setQuery( $sql, 0, 1 );


        $row = null;
        $row = $this->_db->loadObject();
        if (isset($row))
        {
                $query = 'UPDATE '. $this->_tbl
                . ' SET ordering = '. (int) $row->ordering
                . ' WHERE '. $this->_tbl_key .' = '. $this->_db->Quote($this->$k)
                ;
                $this->_db->setQuery( $query );

                if (!$this->_db->query())
                {
                        $err = $this->_db->getErrorMsg();
                        JError::raiseError( 500, $err );
                }

                $query = 'UPDATE '.$this->_tbl
                . ' SET ordering = '.(int) $this->ordering
                . ' WHERE '.$this->_tbl_key.' = '.$this->_db->Quote($row->$k)
                ;
                $this->_db->setQuery( $query );

                if (!$this->_db->query())
                {
                        $err = $this->_db->getErrorMsg();
                        JError::raiseError( 500, $err );
                }

                $this->ordering = $row->ordering;
        }
        else
        {
                $query = 'UPDATE '. $this->_tbl
                . ' SET ordering = '.(int) $this->ordering
                . ' WHERE '. $this->_tbl_key .' = '. $this->_db->Quote($this->$k)
                ;
                $this->_db->setQuery( $query );

                if (!$this->_db->query())
                {
                        $err = $this->_db->getErrorMsg();
                        JError::raiseError( 500, $err );
                }
        }
        return true;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]