Detailed Description
Class provides data access routine.
- Author
- Dodonov A.A.
Definition at line 26 of file review_access.php.
Constructor & Destructor Documentation
Constructor.
- Author
- Dodonov A.A.
Definition at line 67 of file review_access.php.
{
try
{
$this->Database =
get_package(
'database' ,
'last' , __FILE__ );
$this->DatabaseAlgorithms =
get_package(
'database::database_algorithms' ,
'last' , __FILE__ );
$this->Security =
get_package(
'security' ,
'last' , __FILE__ );
$this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
$this->UserAccess =
get_package(
'user::user_access' ,
'last' , __FILE__ );
$this->UserAlgorithms =
get_package(
'user::user_algorithms' ,
'last' , __FILE__ );
}
catch( Exception $e )
{
}
}
Member Function Documentation
Creating record.
- Parameters
-
| $Record | - Example for creation. |
- Returns
- id of the created record.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 338 of file review_access.php.
{
try
{
list( $MasterLink , $Record ) = $this->fetch_data( $Record );
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record ,
CREATION_DATE );
$id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
$Link->create_link(
get_field( $MasterLink ,
'master_id' ) , $id ,
get_field( $MasterLink ,
'master_type' ) ,
'review'
);
$EventManager =
get_package(
'event_manager' ,
'last' , __FILE__ );
$EventManager->trigger_event( 'on_after_create_review' , array( 'id' => $id ) );
return( $id );
}
catch( Exception $e )
{
}
}
| delete |
( |
|
$id, |
|
|
|
$Options = ' 1 = 1' |
|
) |
| |
Deleting records.
- Parameters
-
| $id | - Record's identificator. |
| $Options | - Additional options. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 255 of file review_access.php.
{
try
{
$Link->delete_link( false , $id , false , 'review' );
$id = $this->Security->get( $id , 'integer_list' );
$this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $id )" );
$this->Database->commit();
}
catch( Exception $e )
{
}
}
| get_total_rank |
( |
|
$Type, |
|
|
|
$id |
|
) |
| |
Function returns total rank of the object.
- Parameters
-
| $Type | - Object type. |
| $id | - Object id. |
- Returns
- Total rank value.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 474 of file review_access.php.
{
try
{
$Type = $this->Security->get( $Type , 'command' );
$id = $this->Security->get( $id , 'command' );
$LinkDictionary =
get_package(
'link::link_dictionary' ,
'last' , __FILE__ );
$LinkType = $LinkDictionary->get_link_type( $Type , 'review' );
$Records = $this->Database->select(
'SUM( '.$this->NativeTable.'.rank ) AS total_rank' , $this->NativeTable.' , umx_link' ,
"umx_link.type = $LinkType AND ".$this->NativeTable.".id = umx_link.object2_id
AND umx_link.object1_id = $id AND ( $this->AddLimitations ) AND $Condition"
);
return( isset( $Records[ 0 ] ) ?
get_field( $Records[ 0 ] ,
'total_rank' ) : 0 );
}
catch( Exception $e )
{
}
}
| select |
( |
|
$Start = false, |
|
|
|
$Limit = false, |
|
|
|
$Field = false, |
|
|
|
$Order = false, |
|
|
|
$Condition = '1 = 1' |
|
) |
| |
Function returns list of records.
- Parameters
-
| $Start | - Number of the first record. |
| $Limit | - Count of records limitation. |
| $Field | - Field to sort by. |
| $Order | - Sorting order. |
| $Condition | - Additional conditions. |
- Returns
- List of records.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 215 of file review_access.php.
{
try
{
$Condition = $this->DatabaseAlgorithms->select_condition(
$Start , $Limit , $Field === false ? $this->NativeTable.'.id' : $Field ,
$Order , $Condition , $this->NativeTable
);
}
catch( Exception $e )
{
}
}
Function selects list of objects.
- Parameters
-
| $id | - Comma separated list of record's id. |
- Returns
- Array of records.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 434 of file review_access.php.
{
try
{
$id = $this->Security->get( $id , 'integer_list' );
return( $this->
unsafe_select( $this->NativeTable.
".id IN ( $id ) ORDER BY creation_date ASC" ) );
}
catch( Exception $e )
{
}
}
| set_add_limitations |
( |
|
$theAddLimitation | ) |
|
Function sets additional limitations.
- Parameters
-
| $theAddLimitation | - Additional limitations. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 114 of file review_access.php.
{
try
{
if( $this->AddLimitations === '1 = 1' )
{
$this->AddLimitations = $theAddLimitation;
}
else
{
throw( new Exception( '"AddLimitations" was already set' ) );
}
}
catch( Exception $e )
{
}
}
| unsafe_select |
( |
|
$Condition | ) |
|
Selecting reviews.
- Parameters
-
| $Condition | - Records selection condition. |
- Returns
- Array of objects.
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 155 of file review_access.php.
{
try
{
return(
$this->Database->select(
$this->UserAccess->NativeTable.'.* , '.$this->NativeTable.
'.id , rank , review , page , creation_date , author' ,
$this->NativeTable.' , '.$this->UserAccess->NativeTable ,
$this->NativeTable.'.author = '.$this->UserAccess->NativeTable.".id
AND ( $this->AddLimitations ) AND $Condition"
)
);
}
catch( Exception $e )
{
}
}
Updating record.
- Parameters
-
| $id | - Comma separated list of record's id. |
| $Record | - Example for update. |
- Exceptions
-
| Exception | An exception of this type is thrown. |
- Author
- Dodonov A.A.
Definition at line 387 of file review_access.php.
{
try
{
$id = $this->Security->get( $id , 'integer_list' );
$Record = $this->SecurityParser->parse_parameters(
$Record , 'rank:integer;review:string' , 'allow_not_set'
);
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
if( isset( $Fields[ 0 ] ) )
{
$this->Database->update(
$this->NativeTable , $Fields , $Values , "( $this->AddLimitations ) AND id IN ( $id )"
);
$this->Database->commit();
}
}
catch( Exception $e )
{
}
}
Field Documentation
| $AddLimitations = '1 = 1' |
| $DatabaseAlgorithms = false |
| $NativeTable = '`umx_review`' |
Table name in wich objects of this entity are stored.
- Author
- Dodonov A.A.
Definition at line 38 of file review_access.php.
The documentation for this class was generated from the following file: