ultimix
content_algorithms.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
27 
38  var $ContentAccess = false;
39  var $Security = false;
40 
51  function __construct()
52  {
53  try
54  {
55  $this->ContentAccess = get_package( 'content::content_access' , 'last' , __FILE__ );
56  $this->Security = get_package( 'security' , 'last' , __FILE__ );
57  }
58  catch( Exception $e )
59  {
60  $Args = func_get_args();_throw_exception_object( __METHOD__ , $Args , $e );
61  }
62  }
63 
86  function object_exists( $id )
87  {
88  try
89  {
90  $id = $this->Security->get( $id , 'integer' );
91 
92  $Records = $this->ContentAccess->unsafe_select( $this->ContentAccess->NativeTable.".id = $id" );
93 
94  return( count( $Records ) === 1 );
95  }
96  catch( Exception $e )
97  {
98  $Args = func_get_args();_throw_exception_object( __METHOD__ , $Args , $e );
99  }
100  }
101 
124  function get_by_id( $id )
125  {
126  try
127  {
128  $id = $this->Security->get( $id , 'integer' );
129 
130  $Records = $this->ContentAccess->unsafe_select( $this->ContentAccess->NativeTable.".id = $id" );
131 
132  if( count( $Records ) == 0 )
133  {
134  throw( new Exception( 'Record was not found' ) );
135  }
136 
137  return( $Records[ 0 ] );
138  }
139  catch( Exception $e )
140  {
141  $Args = func_get_args();_throw_exception_object( __METHOD__ , $Args , $e );
142  }
143  }
144  }
145 
146 ?>