本文整理汇总了PHP中Globals::getDBConn方法的典型用法代码示例。如果您正苦于以下问题:PHP Globals::getDBConn方法的具体用法?PHP Globals::getDBConn怎么用?PHP Globals::getDBConn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Globals
的用法示例。
在下文中一共展示了Globals::getDBConn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAll
public static function getAll($unFiltered = true)
{
$db = Globals::getDBConn();
$select = $db->select()->from('session')->order('start DESC');
if ($unFiltered == false) {
$select->where('deleted != 1');
}
$rows = $select->query()->fetchAll();
$sessions = array();
foreach ($rows as $row) {
$sessions[] = new SessionModel($row['id']);
}
return $sessions;
}
示例2: indexAction
public function indexAction()
{
$db = Globals::getDBConn();
$json = Zend_Filter::filterStatic($this->getRequest()->getParam('json'), 'StripTags');
// If the server's magic quotes setting is enabled
if (get_magic_quotes_gpc()) {
$json = Zend_Filter::filterStatic(stripslashes($this->getRequest()->getParam('json')), 'StripTags');
}
$sync = new SyncModel();
if ($sync->commit($json)) {
$this->view->result = true;
} else {
$this->view->result = false;
$this->view->error = $sync->getError();
}
}
示例3: updateloctreeAction
public function updateloctreeAction()
{
$locTree = json_decode(Zend_Filter::filterStatic($this->getRequest()->getParam('loc_tree'), 'StripTags'), true);
if (!$locTree) {
$this->view->error = 'Problem parsing tree';
Globals::getLog()->err('ADMIN update location tree error: ' . $this->view->error);
$this->render('error-xhr');
return false;
}
try {
$db = Globals::getDBConn();
$db->beginTransaction();
LocationModel::updateLocTree($locTree);
$db->commit();
} catch (Exception $e) {
$db->rollBack();
$this->view->error = $e->getMessage();
Globals::getLog()->err('ADMIN update location tree error: ' . $this->view->error);
$this->render('error-xhr');
return false;
}
return true;
}
示例4: updateActivitiesArray
public static function updateActivitiesArray($activities, $initID = null)
{
if (!$initID || !$activities || !is_array($activities) || !is_numeric($initID)) {
throw new Exception('Invalid data structure');
}
try {
$db = Globals::getDBConn();
$db->beginTransaction();
foreach ($activities as $actGroupKey => $activityGroup) {
if (isset($activityGroup['title']) && strlen($activityGroup['title']) > 0 && isset($activityGroup['id']) && isset($activityGroup['desc']) && isset($activityGroup['required']) && isset($activityGroup['allowMulti'])) {
$actGroupData = array('title' => $activityGroup['title'], 'desc' => $activityGroup['desc'], 'rank' => $actGroupKey, 'required' => (int) $activityGroup['required'], 'allowMulti' => (int) $activityGroup['allowMulti']);
if (is_numeric($activityGroup['id'])) {
$activityGroupObj = new ActivityGroupModel($activityGroup['id']);
if (!$activityGroupObj) {
throw new Exception('Failed to retrieve activity group');
}
$activityGroupObj->update($actGroupData);
$activityGroupID = $activityGroupObj->getMetadata('id');
} else {
if ('new-act-group' === $activityGroup['id']) {
$actGroupData['init'] = $initID;
$activityGroupID = ActivityGroupModel::create($actGroupData);
if (false === $activityGroupID) {
throw new Exception('Failed to create activity group');
}
} else {
throw new Exception('Invalid activity group ID');
}
}
foreach ($activityGroup['activities'] as $actKey => $activity) {
if (isset($activity['title']) && strlen($activity['title']) > 0 && isset($activity['id']) && isset($activity['desc']) && isset($activity['enabled'])) {
$actData = array('title' => $activity['title'], 'desc' => $activity['desc'], 'enabled' => (int) $activity['enabled'], 'group' => $activityGroupID, 'rank' => $actKey);
if (is_numeric($activity['id'])) {
$activityObj = new ActivityModel($activity['id']);
if (!$activityObj) {
throw new Exception('Failed to retrieve activity');
}
$activityObj->update($actData);
} else {
if ('new-act' === $activity['id']) {
//$actData['init'] = $initID;
$activityID = self::create($actData);
if (false === $activityID) {
throw new Exception('Failed to create activity');
}
} else {
throw new Exception('Invalid activity ID');
}
}
} else {
throw new Exception('Missing required activity fields (title, ID, enabled, or desc)');
}
}
} else {
throw new Exception('Missing required activity group fields (title, ID, required, allowMulti, or desc)');
}
}
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
return true;
}
示例5: uniqueSessionCheck
private function uniqueSessionCheck($start, $end, $counts, $initId)
{
$db = Globals::getDBConn();
$select = $db->select()->from('session')->where('start = \'' . $start . '\' AND end = \'' . $end . '\' AND fk_initiative = ' . $initId);
$sessions = $select->query()->fetchAll();
foreach ($sessions as $session) {
if (is_numeric($session['id'])) {
$select = $db->select()->from('count')->where('fk_session = ' . $session['id']);
if ($counts == count($select->query()->fetchAll())) {
return false;
}
}
}
return true;
}
示例6: getInitiatives
static function getInitiatives()
{
$db = Globals::getDBConn();
$select = $db->select()->from(array('i' => 'initiative'), array('title', 'id', 'description', 'enabled', 'rootLocation' => 'fk_root_location'))->join(array('s' => 'session'), 'i.id = s.fk_initiative', array())->where('s.deleted = 0')->group('i.id')->order(array('i.title ASC'));
$initiatives = $select->query()->fetchAll();
// This block is to cast string id into an int
$parentArray = array();
foreach ($initiatives as $init) {
$array = array();
foreach ($init as $key => $val) {
if ($key === 'id' || $key === 'rootLocation') {
$array[$key] = (int) $val;
} elseif ($key === 'enabled') {
$array[$key] = (bool) $val;
} else {
$array[$key] = $val;
}
}
$qModel = new QueryModel($array['id']);
$array['dictionary']['locations'] = $qModel->getInitLocs();
$array['dictionary']['activities'] = $qModel->getInitActs();
$array['dictionary']['activityGroups'] = $qModel->getInitActGroups();
$parentArray[] = $array;
}
return $parentArray;
}
示例7: getLocTreeRoots
public static function getLocTreeRoots($filterDisabled = false)
{
$db = Globals::getDBConn();
$select = $db->select()->from('location');
if ($filterDisabled) {
$select->where('enabled = 1 AND fk_parent IS NULL');
} else {
$select->where('fk_parent IS NULL');
}
$rows = $select->order('title ASC')->query()->fetchAll();
$roots = array();
foreach ($rows as $row) {
$roots[] = new LocationModel($row['id']);
}
return $roots;
}
示例8: create
public static function create($data)
{
$db = Globals::getDBConn();
$hash = array('title' => isset($data['title']) ? $data['title'] : 'Default', 'rank' => isset($data['rank']) ? $data['rank'] : 1, 'description' => isset($data['descr']) ? $data['descr'] : null, 'required' => isset($data['required']) ? (int) $data['required'] : 0, 'allowMulti' => isset($data['allowMulti']) ? (int) $data['allowMulti'] : 1, 'fk_initiative' => $data['init']);
$select = $db->select()->from('activity_group')->where('fk_initiative = ' . $hash['fk_initiative'] . ' AND LOWER(title) = ' . $db->quote(strtolower($hash['title'])));
$existingActivityGroup = $select->query()->fetch();
if (empty($existingActivityGroup)) {
$db->insert('activity_group', $hash);
$actGrpId = $db->lastInsertId();
Globals::getLog()->info('ACTIVITY GROUP CREATED - id: ' . $actGrpId . ', title: ' . $data['title'] . ', init: ' . $data['init']);
} else {
$errStr = 'DUPLICATE ACTIVITY GROUP CREATION DENIED - title: ' . $data['title'];
Globals::getLog()->warn($errStr);
throw new Exception($errStr);
}
return $actGrpId;
}
示例9: getAll
public static function getAll($filterDisabled = false)
{
$db = Globals::getDBConn();
$select = $db->select()->from('initiative');
if ($filterDisabled) {
$select->where('enabled = 1');
}
$rows = $select->order('title ASC')->query()->fetchAll();
$inits = array();
foreach ($rows as $row) {
$inits[] = new InitiativeModel($row['id']);
}
return $inits;
}