2005-06-21 23:44:49 +00:00
|
|
|
<?php
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// + $Id$
|
|
|
|
// +------------------------------------------------------------------+ //
|
2005-07-04 02:07:21 +00:00
|
|
|
// + Cake PHP : Rapid Development Framework <http://www.cakephp.org/> + //
|
2005-07-04 02:59:39 +00:00
|
|
|
// + Copyright: (c) 2005, CakePHP Authors/Developers + //
|
2005-06-21 23:44:49 +00:00
|
|
|
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
|
|
|
|
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
|
|
|
|
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
|
|
|
|
// +------------------------------------------------------------------+ //
|
|
|
|
// + Licensed under The MIT License + //
|
|
|
|
// + Redistributions of files must retain the above copyright notice. + //
|
|
|
|
// + See: http://www.opensource.org/licenses/mit-license.php + //
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Purpose: Object
|
|
|
|
* Allows for __construct to be used in PHP4.
|
|
|
|
*
|
|
|
|
* @filesource
|
2005-07-04 02:07:21 +00:00
|
|
|
* @author CakePHP Authors/Developers
|
2005-07-04 02:59:39 +00:00
|
|
|
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
|
2005-07-04 01:07:14 +00:00
|
|
|
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
|
2005-06-21 23:44:49 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.libs
|
2005-07-04 02:07:21 +00:00
|
|
|
* @since CakePHP v 0.2.9
|
2005-06-21 23:44:49 +00:00
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
|
|
|
|
|
|
|
uses('log');
|
|
|
|
|
|
|
|
/**
|
2005-06-22 23:16:26 +00:00
|
|
|
* Object class, allowing __construct and __destruct in PHP4.
|
2005-06-21 23:44:49 +00:00
|
|
|
*
|
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.libs
|
2005-07-04 02:07:21 +00:00
|
|
|
* @since CakePHP v 0.2.9
|
2005-06-21 23:44:49 +00:00
|
|
|
*/
|
|
|
|
class Object
|
|
|
|
{
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* Database connection, if available.
|
|
|
|
*
|
|
|
|
* @var DBO
|
|
|
|
*/
|
|
|
|
var $db = null;
|
2005-06-21 23:44:49 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* A hack to support __construct() on PHP 4
|
|
|
|
* Hint: descendant classes have no PHP4 class_name() constructors,
|
|
|
|
* so this constructor gets called first and calls the top-layer __construct()
|
|
|
|
* which (if present) should call parent::__construct()
|
|
|
|
*
|
|
|
|
* @return Object
|
|
|
|
*/
|
|
|
|
function Object()
|
|
|
|
{
|
|
|
|
$this->db =& DboFactory::getInstance();
|
|
|
|
$args = func_get_args();
|
|
|
|
register_shutdown_function(array(&$this, '__destruct'));
|
|
|
|
call_user_func_array(array(&$this, '__construct'), $args);
|
|
|
|
}
|
2005-06-21 23:44:49 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* Class constructor, overridden in descendant classes.
|
|
|
|
*/
|
2005-07-16 06:10:56 +00:00
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
}
|
2005-06-21 23:44:49 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* Class destructor, overridden in descendant classes.
|
|
|
|
*/
|
2005-07-16 06:10:56 +00:00
|
|
|
function __destruct()
|
|
|
|
{
|
|
|
|
}
|
2005-06-21 23:44:49 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* Object-to-string conversion.
|
|
|
|
* Each class can override it as necessary.
|
|
|
|
*
|
|
|
|
* @return string This name of this class
|
|
|
|
*/
|
|
|
|
function toString()
|
|
|
|
{
|
|
|
|
return get_class($this);
|
|
|
|
}
|
2005-06-21 23:44:49 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
/**
|
|
|
|
* API for logging events.
|
|
|
|
*
|
|
|
|
* @param string $msg Log message
|
|
|
|
* @param int $type Error type constant. Defined in /libs/log.php.
|
|
|
|
*/
|
|
|
|
function log ($msg, $type=LOG_ERROR)
|
|
|
|
{
|
|
|
|
if (!$this->_log)
|
|
|
|
{
|
|
|
|
$this->_log = new Log ();
|
|
|
|
}
|
2005-06-21 23:44:49 +00:00
|
|
|
|
2005-07-10 05:08:19 +00:00
|
|
|
switch ($type)
|
|
|
|
{
|
|
|
|
case LOG_DEBUG:
|
|
|
|
return $this->_log->write('debug', $msg);
|
|
|
|
default:
|
|
|
|
return $this->_log->write('error', $msg);
|
|
|
|
}
|
|
|
|
}
|
2005-06-21 23:44:49 +00:00
|
|
|
}
|
|
|
|
|
2005-05-15 21:41:38 +00:00
|
|
|
?>
|