<?php
/**
* Class used for creating the core of the library that allows
* drivers and objects to share some protected attributes
*
* @package pop
* @subpackage core
*/
abstract class POPCore
{
/**
* Used to hold the id of the object on the database
*
* @access protected
* @var string
*/
protected $id;
/**
* Database connection that will be used by the object/class must be a
* PDO connection object protected $pop_db;
*
* @access protected
* @var string
*/
protected $pop_db = "pop_db";
/**
* Type of the database in use
*
* @access protected
* @var string
*/
protected $pop_dbtype;
/**
* Internal use - An Instance of the class from which this extends
*
* @access protected
* @var string
*/
protected $pop_parent;
/**
* Internal use - The class name from which this extends
*
* @access protected
* @var string
*/
protected $pop_parent_type;
/**
* Internal use - Array of Attributes of this object
*
* @access protected
* @var string
*/
protected $pop_attrs;
/**
* Internal use - Array of Attributes of this object parents
*
* @access protected
* @var string
*/
protected $pop_parent_attrs;
/**
* Internal use - Array of Attributes only avaliable on this object
*
* @access protected
* @var string
*/
protected $pop_self_attrs;
/**
* Internal use - Name of the schema on the database
*
* @access protected
* @var string
*/
protected $pop_schema;
/**
* Used to load objects specialized from existent parents
*
* @access protected
* @var string
*/
protected $id_self;
/**
* Internal use - Name of the table on the database
*
* @access protected
* @var string
*/
protected $pop_table;
/**
* Name of the parent's schema on the database declared for metamapping
*
* @access protected
* @var string
*/
protected $pop_parent_schema;
/**
* Name of the parent's table on the database declared for metamapping
*
* @access protected
* @var string
*/
protected $pop_parent_table;
/**
* Holds the driver for the current database
*
* @access protected
* @var string
*/
protected $pop_db_driver;
/**
* Classes that contains this class (used for ORM)
*
* @access protected
* @var string
*/
protected $pop_parent_classes;
/**
* Metamapping of Attributes and Fields on the Database
* @access protected
* @var string
*/
protected $pop_meta_mapping;
/**
* Check if the attribute can be used, or if it's an internal attribute
*
* @return bool
*/
protected function checkAttrName($key)
{
if (
$key != "id_self" &&
$key != "pop_db" &&
$key != "pop_dbtype" &&
$key != "pop_parent" &&
$key != "pop_parent_type" &&
$key != "pop_attrs" &&
$key != "pop_parent_attrs" &&
$key != "pop_self_attrs" &&
$key != "pop_schema" &&
$key != "pop_table" &&
$key != "pop_parent_schema" &&
$key != "pop_parent_table" &&
$key != "pop_db_driver" &&
$key != "parent_classes" &&
$key != "pop_parent_classes" &&
$key != "schema" &&
$key != "table" &&
$key != "meta_mapping" &&
$key != "pop_meta_mapping"
)
return true;
return false;
}
/**
* Get the table name of the parent object
*
* @return string
*/
protected function getParentTable()
{
if ($this->pop_parent_type != "Persist")
{
return $this->pop_parent->getParentTable();
}
else
return $this->getTargetName();
}
/**
* Check if the attribute exists with that name
*
* @return bool
*/
protected function checkAttrExistence($key)
{
foreach ($this->pop_attrs as $var => $objvalue)
if ($key == $var)
return true;
return false;
}
/**
* Check if the attribute exists with that name on the parent
*
* @return bool
*/
protected function checkParentAttrExistence($key)
{
foreach ($this->pop_parent_attrs as $var => $parobjvalue)
if ($key == $var)
return true;
return false;
}
}
?>