ultimix
db_markup.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  {
28 
39  var $Database = false;
40  var $String = false;
41  var $Utilities = false;
42 
53  function __construct()
54  {
55  try
56  {
57  $this->Database = get_package( 'database' , 'last' , __FILE__ );
58  $this->String = get_package( 'string' , 'last' , __FILE__ );
59  $this->Utilities = get_package( 'utilities' , 'last' , __FILE__ );
60  }
61  catch( Exception $e )
62  {
63  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
64  }
65  }
66 
89  function compile_query_field( &$Settings )
90  {
91  try
92  {
93  $Result = $this->Database->query( $Settings->get_setting( 'query' ) );
94  $Result = $this->Database->fetch_results( $Result );
95 
96  if( isset( $Result[ 0 ] ) )
97  {
98  $Result = $Result[ 0 ];
99  }
100  else
101  {
102  throw( new Exception( "No data found for the query \"$Query\"" ) );
103  }
104 
105  return( get_field( $Result , $Settings->get_setting( 'field' ) ) );
106  }
107  catch( Exception $e )
108  {
109  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
110  }
111  }
112 
135  function compile_record_field( &$Settings )
136  {
137  try
138  {
139  $Value = '';
140  $id = $Settings->get_setting( 'id' );
141 
142  if( $id != '0' )
143  {
144  $PackageObject = $this->Utilities->get_package( $Settings , __FILE__ , 'access_' );
145 
146  if( method_exists( $PackageObject , 'get_by_id' ) == false )
147  {
148  $Message = 'The method "get_by_id" was not found in class '.get_class( $PackageObject );
149  throw( new Exception( $Message ) );
150  }
151 
152  $Record = call_user_func( array( $PackageObject , 'get_by_id' ) , $id );
153 
154  $Field = $Settings->get_setting( 'field' );
155  $Value = get_field( $Record , $Field );
156  }
157 
158  return( $Value );
159  }
160  catch( Exception $e )
161  {
162  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
163  }
164  }
165  }
166 
167 ?>