ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
ordering_1_0_0 Class Reference

## Public Member Functions
| set_table_name ($NewTableName)
| __construct ()
| get_item ($id, $Condition= '1=1')
| get_next_order_item ($Order, $Condition= '1=1')
| get_prev_order_item ($Order, $Condition= '1=1')
| swap_items ($Item1, $Item2, $Condition= '1=1')
| shift_next ($id, $Condition= '1=1')
| shift_prev ($id, $Condition= '1=1')

## Data Fields
| $Database = false
| $Security = false
| $Table

## Detailed Description

Class provides records ordering routine.

Author
  Dodonov A.A.

Definition at line 26 of file ordering.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 82 of file ordering.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

get_item | ( |  | $id,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Функция выборки необходимого элемента.

Parameters

  $id | - Идентификатор записи.
  $Condition | - Условие выборки записи.

Returns
  Запись.

Author
  Додонов А.А.

Definition at line 106 of file ordering.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Items = $this->Database->select( '*' , $this->Table , "id = $id AND $Condition" );
if( count( $Items ) == 1 )
{
return( $Items[ 0 ] );
}
throw( new Exception( "An error occured while getting item".mysql_error() ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_next_order_item | ( |  | $Order,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Функция получения следующего элемента.

Parameters

  $Order | - Порядок Сдвигаемой записи.
  $Condition | - Условие выборки записей.

Returns
  Запись. Или false если следующего элемента не найденно.

Author
  Додонов А.А.

Definition at line 138 of file ordering.php.

{
try
{
$Order = $this->Security->get( $Order , 'string' );
$NextItem = $this->Database->select(
'*' , $this->Table ,
"`order` >= $Order AND $Condition ORDER BY `order` ASC LIMIT 0 , 2"
);
if( isset( $NextItem[ 1 ] ) )
{
return( $NextItem[ 1 ] );
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

get_prev_order_item | ( |  | $Order,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Функция получения предыдущего элемента.

Parameters

  $Order | - Порядок сдвигаемой записи.
  $Condition | - Условие выборки записей.

Returns
  Запись. Или false если предыдущего элемента не найденно.

Author
  Додонов А.А.

Definition at line 173 of file ordering.php.

{
try
{
$Order = $this->Security->get( $Order , 'string' );
$PrevItem = $this->Database->select(
'*' , $this->Table ,
"`order` <= $Order AND $Condition ORDER BY `order` DESC LIMIT 0 , 2"
);
if( isset( $PrevItem[ 1 ] ) )
{
return( $PrevItem[ 1 ] );
}
return( false );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

set_table_name | ( |  | $NewTableName | ) |

Setting fields.

Author
  Dodonov A.A.

Definition at line 63 of file ordering.php.

{
$this->Table = $NewTableName;
}

shift_next | ( |  | $id,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Функция сдвига записи вперёд.

Parameters

  $id | - Идентификатор сдвигаемой записи.
  $Condition | - Условие выборки записей.

Author
  Додонов А.А.

Definition at line 239 of file ordering.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Item = $this->get_item( $id , $Condition );
$NextItem = $this->get_next_order_item( $Item[ 'order' ] , $Condition );
if( $NextItem === false )
{
return;
}
$this->swap_items( $Item , $NextItem , $Condition );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

shift_prev | ( |  | $id,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Функция сдвига записи назад.

Parameters

  $id | - Идентификатор сдвигаемой записи.
  $Condition | - Условие выборки записей.

Author
  Додонов А.А.

Definition at line 270 of file ordering.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Item = $this->get_item( $id , $Condition );
$PrevItem = $this->get_prev_order_item( $Item[ 'order' ] , $Condition );
if( $PrevItem === false )
{
return;
}
$this->swap_items( $Item , $PrevItem , $Condition );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

swap_items | ( |  | $Item1,
|  |  | $Item2,
|  |  | $Condition = `'1 = 1'`
| ) |  |

Меняем элементы местами.

Parameters

  $Item1 | - Один из меняемых элементов.
  $Item2 | - Один из меняемых элементов.
  $Condition | - Условие выборки записей.

Author
  Додонов А.А.

Definition at line 208 of file ordering.php.

{
try
{
$this->Database->update(
$this->Table , array( '`order`' ) ,
get_field( $Item2 , 'order' ) ,
"id = ".get_field( $Item1 , 'id' )
);
$this->Database->update(
$this->Table , array( '`order`' ) ,
get_field( $Item1 , 'order' ) ,
"id = ".get_field( $Item2 , 'id' )
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$Database = false

Cached packages.

Author
  Dodonov A.A.

Definition at line 38 of file ordering.php.

$Security = false

Definition at line 39 of file ordering.php.

$Table

Table's name.

Author
  Dodonov A.A.

Definition at line 51 of file ordering.php.

The documentation for this class was generated from the following file:

- packages/database/packages/ordering/ordering.php