/** * @return Connection */ public function getConnection() { if (!$this->connection) { $this->connection = Database::connection(); } return $this->connection; }
/** * {@inheritDoc} */ public function handle() { $this->setPageTitle("concrete5 has encountered an issue."); $result = self::QUIT; $enabled = Config::get('concrete.debug.display_errors'); if ($enabled) { $detail = Config::get('concrete.debug.detail', 'message'); if ($detail === 'debug') { $this->addDetails(); $result = parent::handle(); } else { $e = $this->getInspector()->getException(); Core::make('helper/concrete/ui')->renderError(t('An unexpected error occurred.'), h($e->getMessage())); } } else { Core::make('helper/concrete/ui')->renderError(t('An unexpected error occurred.'), t('An error occurred while processing this request.')); } if (Config::get('concrete.log.errors')) { try { $e = $this->getInspector()->getException(); $db = Database::get(); if ($db->isConnected()) { $l = new Logger(LOG_TYPE_EXCEPTIONS); $l->emergency(sprintf("Exception Occurred: %s:%d %s (%d)\n", $e->getFile(), $e->getLine(), $e->getMessage(), $e->getCode()), array($e)); } } catch (\Exception $e) { } } return $result; }
public function delete() { $db = Database::connection(); $db->Execute('delete from AttributeFormsAttributeValues where afID = ? and akID = ? and avID = ?', array($this->item->getID(), $this->attributeKey->getAttributeKeyID(), $this->getAttributeValueID())); // Before we run delete() on the parent object, we make sure that attribute value isn't being referenced in the table anywhere else $num = $db->GetOne('select count(avID) from AttributeFormsAttributeValues where avID = ?', array($this->getAttributeValueID())); if ($num < 1) { parent::delete(); } }
public function setAttributes($attributes) { if (is_array($attributes)) { $db = Database::connection(); $db->Execute('DELETE FROM AttributeFormTypeAttributes WHERE aftID = ?', array($this->getID())); $sortOrder = 1; foreach ($attributes as $akID) { $data = ['aftID' => $this->getID(), 'akID' => $akID, 'sortOrder' => $sortOrder++]; $db->insert('AttributeFormTypeAttributes', $data); } } }
/** * {@inheritDoc} */ public function handle() { $this->setPageTitle("concrete5 has encountered an issue."); if (Config::get('concrete.log.errors')) { try { $e = $this->getInspector()->getException(); $db = Database::get(); if ($db->isConnected()) { $l = new Logger(LOG_TYPE_EXCEPTIONS); $l->emergency(t('Exception Occurred: ') . sprintf("%s:%d %s (%d)\n", $e->getFile(), $e->getLine(), $e->getMessage(), $e->getCode()), array($e)); } } catch (Exception $e) { } } $debug = Config::get('concrete.debug.level', 0); if ($debug === DEBUG_DISPLAY_ERRORS) { $this->addDetails(); return parent::handle(); } Core::make('helper/concrete/ui')->renderError(t('An unexpected error occurred.'), t('An error occurred while processing this request.')); Core::shutdown(); }
public static function getParametersForQuery($query) { $db = Database::get(); return $db->GetCol('select params from SystemDatabaseQueryLog where query = ? order by params asc', array($query)); }
public function update($pTemplateHandle, $pTemplateName, $pTemplateIcon = FILENAME_PAGE_TEMPLATE_DEFAULT_ICON) { $this->pTemplateHandle = $pTemplateHandle; $this->pTemplateName = $pTemplateName; $this->pTemplateIcon = $pTemplateIcon; $em = Database::get()->getEntityManager(); $em->persist($this); $em->flush(); }
public function delete() { parent::delete(); $db = Database::connection(); $r = $db->Execute('select avID from AttributeFormsAttributeValues where akID = ?', array($this->getAttributeKeyID())); while ($row = $r->FetchRow()) { $db->Execute('delete from AttributeValues where avID = ?', array($row['avID'])); } $db->Execute('delete from AttributeFormsAttributeValues where akID = ?', array($this->getAttributeKeyID())); }
public function deleteValue() { $db = Database::connection(); $db->Execute('delete from atAttributeSwitcher where avID = ?', array($this->getAttributeValueID())); }
public function getAttributeValueObject($ak, $createIfNotFound = false) { $db = Database::connection(); $av = false; $v = array($this->getID(), $ak->getAttributeKeyID()); $avID = $db->GetOne("select avID from AttributeFormsAttributeValues where afID = ? and akID = ?", $v); if ($avID > 0) { $av = AttributeFormValue::getByID($avID); if (is_object($av)) { $av->setAttributeForm($this); $av->setAttributeKey($ak); } } if ($createIfNotFound) { $cnt = 0; // Is this avID in use ? if (is_object($av)) { $cnt = $db->GetOne("select count(avID) from AttributeFormsAttributeValues where avID = ?", $av->getAttributeValueID()); } if (!is_object($av) || $cnt > 1) { $av = $ak->addAttributeValue(); } } return $av; }