本文整理汇总了PHP中Loader::db方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::db方法的具体用法?PHP Loader::db怎么用?PHP Loader::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uninstall
public function uninstall()
{
parent::uninstall();
$db = Loader::db();
$db->Execute('DROP TABLE btCustomContactForm');
//Do NOT drop package-level tables -- we don't want to accidentally lose submission data!
}
示例2: getAllowedPageTypeIDs
protected function getAllowedPageTypeIDs()
{
$u = new User();
$pae = $this->getPermissionAccessObject();
if (!is_object($pae)) {
return array();
}
$accessEntities = $u->getUserAccessEntityObjects();
$accessEntities = $pae->validateAndFilterAccessEntities($accessEntities);
$list = $this->getAccessListItems(PagePermissionKey::ACCESS_TYPE_ALL, $accessEntities);
$list = PermissionDuration::filterByActive($list);
$db = Loader::db();
$allCTIDs = $db->GetCol('select ctID from PageTypes where ctIsInternal = 0');
$ctIDs = array();
foreach ($list as $l) {
if ($l->getPageTypesAllowedPermission() == 'N') {
$ctIDs = array();
}
if ($l->getPageTypesAllowedPermission() == 'C') {
if ($l->getAccessType() == PagePermissionKey::ACCESS_TYPE_EXCLUDE) {
$ctIDs = array_values(array_diff($ctIDs, $l->getPageTypesAllowedArray()));
} else {
$ctIDs = array_unique(array_merge($ctIDs, $l->getPageTypesAllowedArray()));
}
}
if ($l->getPageTypesAllowedPermission() == 'A') {
$ctIDs = $allCTIDs;
}
}
return $ctIDs;
}
示例3: run
public function run()
{
$sp = Page::getByPath('/dashboard/system/seo/excluded');
if (!is_object($sp) || $sp->isError()) {
$sp = SinglePage::add('/dashboard/system/seo/excluded');
$sp->update(array('cName' => t('Excluded URL Word List')));
$sp->setAttribute('meta_keywords', 'pretty, slug');
}
$bt = BlockType::getByHandle('next_previous');
if (is_object($bt)) {
$bt->refresh();
}
$db = Loader::db();
$columns = $db->MetaColumns('Pages');
if (isset($columns['PTID'])) {
$db->Execute('alter table Pages drop column ptID');
}
if (isset($columns['CTID'])) {
$db->Execute('alter table Pages drop column ctID');
}
$bt = BlockType::getByHandle('search');
if (is_object($bt)) {
$bt->refresh();
}
}
示例4: save
public function save($args)
{
parent::save();
$db = Loader::db();
$db->Execute('delete from FileSetPermissionFileTypeAccessList where paID = ?', array($this->getPermissionAccessID()));
$db->Execute('delete from FileSetPermissionFileTypeAccessListCustom where paID = ?', array($this->getPermissionAccessID()));
if (is_array($args['fileTypesIncluded'])) {
foreach ($args['fileTypesIncluded'] as $peID => $permission) {
$v = array($this->getPermissionAccessID(), $peID, $permission);
$db->Execute('insert into FileSetPermissionFileTypeAccessList (paID, peID, permission) values (?, ?, ?)', $v);
}
}
if (is_array($args['fileTypesExcluded'])) {
foreach ($args['fileTypesExcluded'] as $peID => $permission) {
$v = array($this->getPermissionAccessID(), $peID, $permission);
$db->Execute('insert into FileSetPermissionFileTypeAccessList (paID, peID, permission) values (?, ?, ?)', $v);
}
}
if (is_array($args['extensionInclude'])) {
foreach ($args['extensionInclude'] as $peID => $extensions) {
foreach ($extensions as $extension) {
$v = array($this->getPermissionAccessID(), $peID, $extension);
$db->Execute('insert into FileSetPermissionFileTypeAccessListCustom (paID, peID, extension) values (?, ?, ?)', $v);
}
}
}
if (is_array($args['extensionExclude'])) {
foreach ($args['extensionExclude'] as $peID => $extensions) {
foreach ($extensions as $extension) {
$v = array($this->getPermissionAccessID(), $peID, $extension);
$db->Execute('insert into FileSetPermissionFileTypeAccessListCustom (paID, peID, extension) values (?, ?, ?)', $v);
}
}
}
}
示例5: addEntry
public static function addEntry($bID, $commentText, $name, $email, $approved, $cID, $uID = 0, $timestamp = null)
{
$txt = Loader::helper('text');
$db = Loader::db();
$query = "INSERT INTO btGuestBookEntries (bID, cID, uID, user_name, user_email, commentText, approved, entryDate) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$v = array($bID, $cID, intval($uID), $txt->sanitize($name), $txt->sanitize($email), $txt->sanitize($commentText), $approved, $timestamp);
$res = $db->query($query, $v);
$number = 1;
//stupid cache stuff
$ca = new Cache();
$db = Loader::db();
$count = $ca->get('GuestBookCount', $cID . "-" . $bID);
if ($count && $number) {
$count += $number;
} else {
$q = 'SELECT count(bID) as count
FROM btGuestBookEntries
WHERE bID = ?
AND cID = ?
AND approved=1';
$v = array($bID, $cID);
$rs = $db->query($q, $v);
$row = $rs->FetchRow();
$count = $row['count'];
}
$ca->set('GuestBookCount', $cID . "-" . $bID, $count);
}
示例6: run
/** Executes the job.
* @return string Returns a string describing the job result in case of success.
* @throws Exception Throws an exception in case of errors.
*/
public function run() {
Cache::disableCache();
Cache::disableLocalCache();
try {
$db = Loader::db();
$instances = array(
'navigation' => Loader::helper('navigation'),
'dashboard' => Loader::helper('concrete/dashboard'),
'view_page' => PermissionKey::getByHandle('view_page')
);
$rsPages = $db->query('SELECT cID FROM Pages WHERE (cID > 1) ORDER BY cID');
$relName = ltrim(SITEMAPXML_FILE, '\\/');
$osName = rtrim(DIR_BASE, '\\/') . '/' . $relName;
$urlName = rtrim(BASE_URL . DIR_REL, '\\/') . '/' . $relName;
if(!file_exists($osName)) {
@touch($osName);
}
if(!is_writable($osName)) {
throw new Exception(t('The file %s is not writable', $osName));
}
if(!$hFile = fopen($osName, 'w')) {
throw new Exception(t('Cannot open file %s', $osName));
}
if(!@fprintf($hFile, '<?xml version="1.0" encoding="%s"?>' . self::EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">', APP_CHARSET)) {
throw new Exception(t('Error writing header of %s', $osName));
}
$addedPages = 0;
if(self::AddPage($hFile, 1, $instances)) {
$addedPages++;
}
while($rowPage = $rsPages->FetchRow()) {
if(self::AddPage($hFile, intval($rowPage['cID']), $instances)) {
$addedPages++;
}
}
$rsPages->Close();
unset($rsPages);
if(!@fwrite($hFile, self::EOL . '</urlset>')) {
throw new Exception(t('Error writing footer of %s', $osName));
}
@fflush($hFile);
@fclose($hFile);
unset($hFile);
return t('%1$s file saved (%2$d pages).', $urlName, $addedPages);
}
catch(Exception $x) {
if(isset($rsPages) && $rsPages) {
$rsPages->Close();
$rsPages = null;
}
if(isset($hFile) && $hFile) {
@fflush($hFile);
@ftruncate($hFile, 0);
@fclose($hFile);
$hFile = null;
}
throw $x;
}
}
示例7: assignPermissionAccess
public function assignPermissionAccess(PermissionAccess $pa)
{
$db = Loader::db();
$db->Replace('PagePermissionAssignments', array('cID' => $this->getPermissionObject()->getPermissionsCollectionID(), 'paID' => $pa->getPermissionAccessID(), 'pkID' => $this->pk->getPermissionKeyID()), array('cID', 'pkID'), true);
$pa->markAsInUse();
PermissionCache::clearAccessObject($this->pk, $this->getPermissionObject());
}
示例8: buildAnswerSetsArray
public static function buildAnswerSetsArray($questionSet, $orderBy = '', $limit = '')
{
$db = Loader::db();
if (strlen(trim($limit)) > 0 && !strstr(strtolower($limit), 'limit')) {
$limit = ' LIMIT ' . $limit;
}
if (strlen(trim($orderBy)) > 0 && array_key_exists($orderBy, self::$sortChoices)) {
$orderBySQL = self::$sortChoices[$orderBy];
} else {
$orderBySQL = self::$sortChoices['newest'];
}
//get answers sets
$sql = 'SELECT * FROM btFormAnswerSet AS aSet ' . 'WHERE aSet.questionSetId=' . $questionSet . ' ORDER BY ' . $orderBySQL . ' ' . $limit;
$answerSetsRS = $db->query($sql);
//load answers into a nicer multi-dimensional array
$answerSets = array();
$answerSetIds = array(0);
while ($answer = $answerSetsRS->fetchRow()) {
//answer set id - question id
$answerSets[$answer['asID']] = $answer;
$answerSetIds[] = $answer['asID'];
}
//get answers
$sql = 'SELECT * FROM btFormAnswers AS a WHERE a.asID IN (' . join(',', $answerSetIds) . ')';
$answersRS = $db->query($sql);
//load answers into a nicer multi-dimensional array
while ($answer = $answersRS->fetchRow()) {
//answer set id - question id
$answerSets[$answer['asID']]['answers'][$answer['msqID']] = $answer;
}
return $answerSets;
}
示例9: restore_backup
public function restore_backup()
{
$tp = new TaskPermission();
if (!$tp->canBackup()) {
return false;
}
$file = $this->post('backup_file');
$db = Loader::db();
chmod(DIR_FILES_BACKUPS . '/' . $file, 0666);
$str_restSql = file_get_contents(DIR_FILES_BACKUPS . '/' . $file);
if (!$str_restSql) {
$this->set("error", array("There was an error trying to restore the database. This file was empty."));
$this->view();
return false;
}
$crypt = Loader::helper('encryption');
if (!preg_match('/INSERT/m', $str_restSql) && !preg_match('/CREATE/m', $str_restSql)) {
$str_restSql = $crypt->decrypt($str_restSql);
}
$arr_sqlStmts = explode("\n\n", $str_restSql);
foreach ($arr_sqlStmts as $str_stmt) {
if (trim($str_stmt) != "") {
$res_restoration = $db->execute($str_stmt);
if (!$res_restoration) {
$this->set("error", array("There was an error trying to restore the database. In query {$str_stmt}"));
return;
}
}
}
$this->set("message", "Restoration Sucessful");
//reset perms for security!
chmod(DIR_FILES_BACKUPS . '/' . $file, 00);
Cache::flush();
$this->view();
}
示例10: getBlockTypeAssetsURL
/**
* Gets a full URL to the directory containing all of a block's items, including JavaScript, tools, icons, etc...
* @param BlockType $bt
* @return string $url
*/
public function getBlockTypeAssetsURL($bt, $file = false)
{
$ff = '';
if ($file != false) {
$ff = '/' . $file;
}
if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $bt->getBlockTypeHandle() . $ff)) {
$url = BASE_URL . DIR_REL . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
} else {
if ($bt->getPackageID() > 0) {
$db = Loader::db();
$h = $bt->getPackageHandle();
$dirp = is_dir(DIR_PACKAGES . '/' . $h) ? DIR_PACKAGES . '/' . $h : DIR_PACKAGES_CORE . '/' . $h;
if (file_exists($dirp . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff)) {
$url = is_dir(DIR_PACKAGES . '/' . $h) ? BASE_URL . DIR_REL : ASSETS_URL;
$url = $url . '/' . DIRNAME_PACKAGES . '/' . $h . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
}
} else {
if (file_exists(DIR_FILES_BLOCK_TYPES_CORE . '/' . $bt->getBlockTypeHandle() . $ff)) {
$url = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $bt->getBlockTypeHandle() . $ff;
}
}
}
return $url;
}
示例11: save
public function save($args)
{
$db = Loader::db();
parent::save();
$db->Execute('delete from AreaPermissionBlockTypeAccessList where paID = ?', array($this->getPermissionAccessID()));
$db->Execute('delete from AreaPermissionBlockTypeAccessListCustom where paID = ?', array($this->getPermissionAccessID()));
if (is_array($args['blockTypesIncluded'])) {
foreach ($args['blockTypesIncluded'] as $peID => $permission) {
$v = array($this->getPermissionAccessID(), $peID, $permission);
$db->Execute('insert into AreaPermissionBlockTypeAccessList (paID, peID, permission) values (?, ?, ?)', $v);
}
}
if (is_array($args['blockTypesExcluded'])) {
foreach ($args['blockTypesExcluded'] as $peID => $permission) {
$v = array($this->getPermissionAccessID(), $peID, $permission);
$db->Execute('insert into AreaPermissionBlockTypeAccessList (paID, peID, permission) values (?, ?, ?)', $v);
}
}
if (is_array($args['btIDInclude'])) {
foreach ($args['btIDInclude'] as $peID => $btIDs) {
foreach ($btIDs as $btID) {
$v = array($this->getPermissionAccessID(), $peID, $btID);
$db->Execute('insert into AreaPermissionBlockTypeAccessListCustom (paID, peID, btID) values (?, ?, ?)', $v);
}
}
}
if (is_array($args['btIDExclude'])) {
foreach ($args['btIDExclude'] as $peID => $btIDs) {
foreach ($btIDs as $btID) {
$v = array($this->getPermissionAccessID(), $peID, $btID);
$db->Execute('insert into AreaPermissionBlockTypeAccessListCustom (paID, peID, btID) values (?, ?, ?)', $v);
}
}
}
}
示例12: txt_editor_config
function txt_editor_config(){
if (!$this->token->validate("txt_editor_config")) {
$this->error->add($this->token->getErrorMessage());
}
$textEditorWidth = intval($this->post('CONTENTS_TXT_EDITOR_WIDTH'));
if( $textEditorWidth<580 ) {
$this->error->add(t('The editor must be at least 580 pixels wide.'));
}
$textEditorHeight = intval($this->post('CONTENTS_TXT_EDITOR_HEIGHT'));
if( $textEditorHeight<100 ) {
$this->error->add(t('The editor must be at least 100 pixels tall.'));
}
if (!$this->error->has()) {
Config::save('CONTENTS_TXT_EDITOR_MODE', $this->post('CONTENTS_TXT_EDITOR_MODE') );
Config::save( 'CONTENTS_TXT_EDITOR_WIDTH', $textEditorWidth );
Config::save( 'CONTENTS_TXT_EDITOR_HEIGHT', $textEditorHeight );
$db = Loader::db();
$values=array( $textEditorWidth, $textEditorHeight );
$db->query( 'UPDATE BlockTypes SET btInterfaceWidth=?, btInterfaceHeight=? where btHandle = "content"', $values );
if($this->post('CONTENTS_TXT_EDITOR_MODE')=='CUSTOM')
Config::save('CONTENTS_TXT_EDITOR_CUSTOM_CODE', $this->post('CONTENTS_TXT_EDITOR_CUSTOM_CODE') );
$this->redirect('/dashboard/system/basics/editor', 'txt_editor_config_saved');
}
}
示例13: save
public function save($args)
{
parent::save();
$db = Loader::db();
$db->Execute('delete from ' . $this->dbTableAccessList . ' where paID = ?', array($this->getPermissionAccessID()));
$db->Execute('delete from ' . $this->dbTableAccessListCustom . ' where paID = ?', array($this->getPermissionAccessID()));
if (is_array($args['groupsIncluded'])) {
foreach ($args['groupsIncluded'] as $peID => $permission) {
$v = array($peID, $this->getPermissionAccessID(), $permission);
$db->Execute('insert into ' . $this->dbTableAccessList . ' (peID, paID, permission) values (?, ?, ?)', $v);
}
}
if (is_array($args['groupsExcluded'])) {
foreach ($args['groupsExcluded'] as $peID => $permission) {
$v = array($peID, $this->getPermissionAccessID(), $permission);
$db->Execute('insert into ' . $this->dbTableAccessList . ' (peID, paID, permission) values (?, ?, ?)', $v);
}
}
if (is_array($args['gIDInclude'])) {
foreach ($args['gIDInclude'] as $peID => $gIDs) {
foreach ($gIDs as $gID) {
$v = array($peID, $this->getPermissionAccessID(), $gID);
$db->Execute('insert into ' . $this->dbTableAccessListCustom . ' (peID, paID, gID) values (?, ?, ?)', $v);
}
}
}
if (is_array($args['gIDExclude'])) {
foreach ($args['gIDExclude'] as $peID => $gIDs) {
foreach ($gIDs as $gID) {
$v = array($peID, $this->getPermissionAccessID(), $gID);
$db->Execute('insert into ' . $this->dbTableAccessListCustom . ' (peID, paID, gID) values (?, ?, ?)', $v);
}
}
}
}
示例14: loadRepositories
protected function loadRepositories()
{
$db = Loader::db();
$sql = "SELECT * FROM btGithubRepositories WHERE bID = ?";
$repositories = $db->getAll($sql, array(intval($this->bID)));
return $repositories;
}
示例15: tearDown
public function tearDown()
{
if (count($this->tables)) {
foreach ($this->tables as $table) {
// drop table
$conn = $this->getConnection();
$pdo = $conn->getConnection();
$pdo->exec("DROP TABLE IF EXISTS `{$table}`;");
}
}
$allTables = $this->getDataSet($this->fixtures)->getTableNames();
foreach ($allTables as $table) {
// drop table
$conn = $this->getConnection();
$pdo = $conn->getConnection();
$pdo->exec("DROP TABLE IF EXISTS `{$table}`;");
}
$db = Loader::db();
$db->getEntityManager()->clear();
Database::purge();
if ($this->conn) {
$this->conn = null;
}
parent::tearDown();
}