本文整理汇总了PHP中PEAR_Singleton::getStaticProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Singleton::getStaticProperty方法的具体用法?PHP PEAR_Singleton::getStaticProperty怎么用?PHP PEAR_Singleton::getStaticProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Singleton
的用法示例。
在下文中一共展示了PEAR_Singleton::getStaticProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connectToDatabase
/**
* Connect to the database.
*
* @return void
* @access public
*/
public static function connectToDatabase()
{
global $configArray;
if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
define('DB_DATAOBJECT_NO_OVERLOAD', 0);
}
$options =& PEAR_Singleton::getStaticProperty('DB_DataObject', 'options');
// If we're using PostgreSQL, we need to set up some extra configuration
// settings so that unique ID sequences are properly registered:
if (substr($configArray['Database']['database'], 0, 5) == 'pgsql') {
$tables = array('comments', 'oai_resumption', 'resource', 'resource_tags', 'search', 'session', 'tags', 'user', 'user_list', 'user_resource');
foreach ($tables as $table) {
$configArray['Database']['sequence_' . $table] = $table . '_id_seq';
}
}
$options = $configArray['Database'];
if (substr($configArray['Database']['database'], 0, 5) == 'mysql') {
// If we're using MySQL, we need to make certain adjustments (ANSI
// quotes, pipes as concatenation operator) for proper compatibility
// with code built for other database systems like PostgreSQL or Oracle.
$obj = new DB_DataObject();
$conn = $obj->getDatabaseConnection();
$conn->query("SET @@SESSION.sql_mode='ANSI_QUOTES,PIPES_AS_CONCAT'");
} else {
if (substr($configArray['Database']['database'], 0, 4) == 'oci8') {
// If we are using Oracle, set some portability values:
$temp_db = new DB_DataObject();
$db =& $temp_db->getDatabaseConnection();
$db->setOption('portability', DB_PORTABILITY_NUMROWS | DB_PORTABILITY_NULL_TO_EMPTY);
// Update the date format to fix issues with Oracle being evil
$db->query("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
}
}
}
示例2: initDatabase
function initDatabase()
{
global $configArray;
// Setup Local Database Connection
define('DB_DATAOBJECT_NO_OVERLOAD', 0);
$options =& PEAR_Singleton::getStaticProperty('DB_DataObject', 'options');
$options = $configArray['Database'];
}
示例3: initDatabaseConnection
private function initDatabaseConnection()
{
// Setup Local Database Connection
if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
define('DB_DATAOBJECT_NO_OVERLOAD', 0);
}
$options =& PEAR_Singleton::getStaticProperty('DB_DataObject', 'options');
$options = $this->configArray['Database'];
$this->logTime("Connect to databse");
require_once ROOT_DIR . '/Drivers/marmot_inc/Library.php';
}
示例4: saveObject
/**
* Save the object to the database (and optionally solr) based on the structure of the object
* Takes care of determining whether or not the object is new or not.
*
* @param $dataObject
* @param $form
*/
static function saveObject($structure, $dataType)
{
global $logger;
//Check to see if we have a new object or an exiting object to update
$object = new $dataType();
DataObjectUtil::updateFromUI($object, $structure);
$primaryKeySet = false;
foreach ($structure as $property) {
if (isset($property['primaryKey']) && $property['primaryKey'] == true) {
if (isset($object->{$property}['property']) && !is_null($object->{$property}['property']) && strlen($object->{$property}['property']) > 0) {
$object = new $dataType();
$object->{$property}['property'] = $object->{$property}['property'];
if ($object->find(true)) {
$logger->log("Loaded existing object from database", PEAR_LOG_DEBUG);
} else {
$logger->log("Could not find existing object in database", PEAR_LOG_ERR);
}
//Reload from UI
DataObjectUtil::updateFromUI($object, $structure);
$primaryKeySet = true;
break;
}
}
}
$validationResults = DataObjectUtil::validateObject($structure, $object);
$validationResults['object'] = $object;
if ($validationResults['validatedOk']) {
//Check to see if we need to insert or update the object.
//We can tell which to do based on whether or not the primary key is set
if ($primaryKeySet) {
$result = $object->update();
$validationResults['saveOk'] = $result == 1;
} else {
$result = $object->insert();
$validationResults['saveOk'] = $result;
}
if (!$validationResults['saveOk']) {
//TODO: Display the PEAR error (in certain circumstances only?)
$error =& PEAR_Singleton::getStaticProperty('DB_DataObject', 'lastError');
if (isset($error)) {
$validationResults['errors'][] = 'Save failed ' . $error->getMessage();
} else {
$validationResults['errors'][] = 'Save failed';
}
}
}
return $validationResults;
}