65 $this->Table = $NewTableName;
86 $this->Database =
get_package(
'database' ,
'last' , __FILE__ );
87 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
110 $id = $this->Security->get( $id ,
'integer' );
112 $Items = $this->Database->select(
'*' , $this->Table ,
"id = $id AND $Condition" );
114 if( count( $Items ) == 1 )
116 return( $Items[ 0 ] );
119 throw(
new Exception(
"An error occured while getting item".mysql_error() ) );
121 catch( Exception $e )
142 $Order = $this->Security->get( $Order ,
'string' );
144 $NextItem = $this->Database->select(
146 "`order` >= $Order AND $Condition ORDER BY `order` ASC LIMIT 0 , 2"
149 if( isset( $NextItem[ 1 ] ) )
151 return( $NextItem[ 1 ] );
156 catch( Exception $e )
177 $Order = $this->Security->get( $Order ,
'string' );
179 $PrevItem = $this->Database->select(
181 "`order` <= $Order AND $Condition ORDER BY `order` DESC LIMIT 0 , 2"
184 if( isset( $PrevItem[ 1 ] ) )
186 return( $PrevItem[ 1 ] );
191 catch( Exception $e )
208 function swap_items( $Item1 , $Item2 , $Condition =
'1 = 1' )
212 $this->Database->update(
213 $this->Table , array(
'`order`' ) ,
218 $this->Database->update(
219 $this->Table , array(
'`order`' ) ,
224 catch( Exception $e )
243 $id = $this->Security->get( $id ,
'integer' );
245 $Item = $this->
get_item( $id , $Condition );
248 if( $NextItem ===
false )
253 $this->
swap_items( $Item , $NextItem , $Condition );
255 catch( Exception $e )
274 $id = $this->Security->get( $id ,
'integer' );
276 $Item = $this->
get_item( $id , $Condition );
279 if( $PrevItem ===
false )
284 $this->
swap_items( $Item , $PrevItem , $Condition );
286 catch( Exception $e )