当前位置: 首页>>代码示例>>PHP>>正文


PHP Jaws_DB::getInstance方法代码示例

本文整理汇总了PHP中Jaws_DB::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_DB::getInstance方法的具体用法?PHP Jaws_DB::getInstance怎么用?PHP Jaws_DB::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Jaws_DB的用法示例。


在下文中一共展示了Jaws_DB::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Execute

 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql   Prepared search(WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     $params = array();
     $sql = '
         SELECT
            [id],[name], [title], [description], [meta_keywords], [meta_description]
         FROM [[tags]]
         ';
     if ($GLOBALS['app']->Session->Logged()) {
         $params['user'] = $GLOBALS['app']->Session->GetAttribute('user');
         $wStr = '([user]=0 OR [user]={user})';
     } else {
         $wStr = '[user]=0';
     }
     $sql .= ' WHERE ' . $wStr;
     $sql .= ' AND ' . $pSql;
     $sql .= ' ORDER BY [id] desc';
     $types = array('integer', 'text', 'text', 'text', 'text', 'text');
     $result = Jaws_DB::getInstance()->queryAll($sql, $params, $types);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $tags = array();
     foreach ($result as $t) {
         $tag = array();
         $tag['title'] = $t['title'];
         $url = $this->gadget->urlMap('ViewTag', array('tag' => $t['name']));
         $tag['url'] = $url;
         $tag['image'] = 'gadgets/Tags/Resources/images/logo.png';
         $tag['snippet'] = $t['description'];
         $tag['date'] = null;
         $tags[$t['id']] = $tag;
     }
     return $tags;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:42,代码来源:Search.php

示例2: GetEnableBanners

 /**
  * Retrieve banners that can be visible
  *
  * @access  public
  * @param   int     $gid   group ID
  * @param   int     $random
  * @return  mixed   An array of available banners or False on error
  */
 function GetEnableBanners($gid = 0, $random = 0)
 {
     $bannersTable = Jaws_ORM::getInstance()->table('banners');
     $bannersTable->select('id:integer', 'title', 'url', 'banner', 'template');
     $bannersTable->where('published', true)->and()->where('random', $random)->and();
     $bannersTable->openWhere('views_limitation', 0)->or();
     $bannersTable->closeWhere('views', $bannersTable->expr('views_limitation'), '<')->and();
     $bannersTable->openWhere('clicks_limitation', 0)->or();
     $bannersTable->closeWhere('clicks', $bannersTable->expr('clicks_limitation'), '<')->and();
     $bannersTable->openWhere('start_time', '', 'is null')->or();
     $bannersTable->closeWhere('start_time', Jaws_DB::getInstance()->date(), '<=')->and();
     $bannersTable->openWhere('stop_time', '', 'is null')->or();
     $bannersTable->closeWhere('stop_time', Jaws_DB::getInstance()->date(), '>=');
     if ($gid == 0) {
         $bannersTable->orderBy('id asc');
     } else {
         $bannersTable->and()->where('gid', $gid);
         $bannersTable->orderBy('id asc');
     }
     $res = $bannersTable->fetchAll();
     if (Jaws_Error::IsError($res)) {
         return false;
     }
     return $res;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:33,代码来源:Banners.php

示例3: Execute

 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql   Prepared search(WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     $sql = '
         SELECT
            [id], [title], [description], [user_filename], [update_time]
         FROM [[directory]]
         WHERE
             [hidden] = {hidden}
         ';
     $sql .= ' AND ' . $pSql;
     $sql .= ' ORDER BY id desc';
     $params = array();
     $params['hidden'] = false;
     $types = array('text', 'text', 'text', 'integer');
     $result = Jaws_DB::getInstance()->queryAll($sql, $params, $types);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $files = array();
     foreach ($result as $p) {
         $file = array();
         $file['title'] = $p['title'];
         $file['url'] = $this->gadget->urlMap('Directory', array('id' => $p['id']));
         $file['image'] = 'gadgets/Directory/Resources/images/logo.png';
         $file['snippet'] = $p['description'];
         $file['date'] = $p['update_time'];
         $stamp = $p['update_time'];
         $files[$stamp] = $file;
     }
     return $files;
 }
开发者ID:uda,项目名称:jaws,代码行数:39,代码来源:Search.php

示例4: Execute

 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql  Prepared search (WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     // TODO: must be converted to Jaws_ORM
     $sql = '
         SELECT
             [id], [title], [contents], [updatetime]
         FROM [[blocks]]
         ';
     $sql .= ' WHERE ' . $pSql;
     $sql .= ' ORDER BY [createtime] desc';
     $result = Jaws_DB::getInstance()->queryAll($sql);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $blocks = array();
     foreach ($result as $r) {
         $block = array();
         $block['title'] = $r['title'];
         $block['url'] = $this->gadget->urlMap('Block', array('id' => $r['id']));
         $block['image'] = 'gadgets/Blocks/Resources/images/logo.png';
         $block['snippet'] = $r['contents'];
         $block['date'] = $date->ToISO($r['updatetime']);
         $blocks[] = $block;
     }
     return $blocks;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:34,代码来源:Search.php

示例5: NewTerm

 /**
  * Adds a new term
  *
  * @acess   public
  * @param   string  $term       Term
  * @param   string  $fast_url
  * @param   string  $desc       Term's description
  * @return  mixed   Returns true if term was added or Jaws_Error on error
  */
 function NewTerm($term, $fast_url, $desc)
 {
     $fast_url = empty($fast_url) ? $term : $fast_url;
     $fast_url = $this->GetRealFastUrl($fast_url, 'glossary');
     $now = Jaws_DB::getInstance()->date();
     $params['term'] = $term;
     $params['fast_url'] = $fast_url;
     $params['description'] = $desc;
     $params['createtime'] = $now;
     $params['updatetime'] = $now;
     $glossaryTable = Jaws_ORM::getInstance()->table('glossary');
     $result = $glossaryTable->insert($params)->exec();
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('GLOSSARY_ERROR_TERM_NOT_CREATED'), RESPONSE_ERROR);
         return new Jaws_Error(_t('GLOSSARY_ERROR_TERM_NOT_CREATED'));
     }
     $GLOBALS['app']->Session->PushLastResponse(_t('GLOSSARY_TERM_ADDED'), RESPONSE_NOTICE);
     $glossaryTable = Jaws_ORM::getInstance()->table('glossary');
     $row = $glossaryTable->select('id:integer')->where('createtime', $now)->fetchRow();
     if (Jaws_Error::IsError($row)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('GLOSSARY_ERROR_TERM_NOT_CREATED'), RESPONSE_ERROR);
         return new Jaws_Error(_t('GLOSSARY_ERROR_TERM_NOT_CREATED'));
     }
     if (isset($row['id'])) {
         return $row['id'];
     }
     return false;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:37,代码来源:Term.php

示例6: Execute

 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql  Prepared search (WHERE) SQL
  * @return  mixed   An array of entries that matches a certain pattern or False on error
  */
 function Execute($pSql = '')
 {
     $sql = '
         SELECT
             [id], [term], [description], [createtime]
         FROM [[glossary]]
         ';
     $sql .= ' WHERE ' . $pSql;
     $sql .= " ORDER BY [createtime] desc";
     $result = Jaws_DB::getInstance()->queryAll($sql);
     if (Jaws_Error::IsError($result)) {
         return false;
     }
     $date = Jaws_Date::getInstance();
     $entries = array();
     foreach ($result as $r) {
         $entry = array();
         $entry['title'] = $r['term'];
         $entry['url'] = $this->gadget->urlMap('ViewTerm', array('term' => $r['id']));
         $entry['image'] = 'gadgets/Glossary/Resources/images/logo.png';
         $entry['snippet'] = $r['description'];
         $entry['date'] = $date->ToISO($r['createtime']);
         $stamp = str_replace(array('-', ':', ' '), '', $r['createtime']);
         $entries[$stamp] = $entry;
     }
     return $entries;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:34,代码来源:Search.php

示例7: NewTrackback

 /**
  * Create a new trackback
  *
  * @access  public
  * @param   int     $parent_id      ID of the entry
  * @param   string  $url            URL of the trackback
  * @param   string  $title          Title of the trackback
  * @param   string  $excerpt        The Excerpt
  * @param   string  $blog_name      The name of the Blog
  * @param   string  $ip             The sender ip address
  * @return  mixed   True if trackback was successfully added, if not, returns Jaws_Error
  */
 function NewTrackback($parent_id, $url, $title, $excerpt, $blog_name, $ip)
 {
     if ($this->gadget->registry->fetch('trackback') == 'true') {
         $model = $this->gadget->model->load('Posts');
         if (!$model->DoesEntryExists($parent_id)) {
             return new Jaws_Error(_t('BLOG_ERROR_DOES_NOT_EXISTS'));
         }
         // lets only load it if it's actually needed
         $now = Jaws_DB::getInstance()->date();
         $trackbackTable = Jaws_ORM::getInstance()->table('blog_trackback');
         $trackbackTable->select('id:integer')->where('parent_id', $parent_id);
         $id = $trackbackTable->and()->where('url', strip_tags($url))->fetchOne();
         $trackData['title'] = strip_tags($title);
         $trackData['excerpt'] = strip_tags($excerpt);
         $trackData['blog_name'] = strip_tags($blog_name);
         $trackData['updatetime'] = $now;
         $trackbackTable = Jaws_ORM::getInstance()->table('blog_trackback');
         if (!Jaws_Error::IsError($id) && !empty($id)) {
             $trackbackTable->update($trackData)->where('id', $id);
         } else {
             $trackData['parent_id'] = $parent_id;
             $trackData['url'] = strip_tags($url);
             $trackData['ip'] = $ip;
             $trackData['status'] = $this->gadget->registry->fetch('trackback_status');
             $trackData['createtime'] = $now;
             $trackbackTable->insert($trackData);
         }
         $result = $trackbackTable->exec();
         if (Jaws_Error::IsError($result)) {
             return new Jaws_Error(_t('BLOG_ERROR_TRACKBACK_NOT_ADDED'));
         }
         return true;
     }
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:47,代码来源:Trackbacks.php

示例8: Execute

 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql   Prepared search (WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     $params = array('active' => true);
     $sql = '
         SELECT
             [category],
             [question],
             [answer],
             [faq_position],
             [updatetime]
         FROM [[faq]]
         WHERE [published] = {active}
         ';
     $sql .= ' AND ' . $pSql;
     $sql .= ' ORDER BY [createtime] desc';
     $result = Jaws_DB::getInstance()->queryAll($sql, $params);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $questions = array();
     $date = Jaws_Date::getInstance();
     foreach ($result as $r) {
         $question = array();
         $question['title'] = $r['question'];
         $question['url'] = $this->gadget->urlMap('ViewCategory', array('id' => $r['category'])) . '#Question' . $r['faq_position'];
         $question['image'] = 'gadgets/Faq/Resources/images/logo.png';
         $question['snippet'] = $r['answer'];
         $question['date'] = $date->ToISO($r['updatetime']);
         $questions[] = $question;
     }
     return $questions;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:39,代码来源:Search.php

示例9: Backup

 /**
  * Returns downloadable backup file
  *
  * @access  public
  * @return void
  */
 function Backup()
 {
     $this->gadget->CheckPermission('Backup');
     $tmpDir = sys_get_temp_dir();
     $domain = preg_replace("/^(www.)|(:{$_SERVER['SERVER_PORT']})\$|[^a-z0-9\\-\\.]/", '', strtolower($_SERVER['HTTP_HOST']));
     $nameArchive = $domain . '-' . date('Y-m-d') . '.tar.gz';
     $pathArchive = $tmpDir . DIRECTORY_SEPARATOR . $nameArchive;
     //Dump database data
     $dbFileName = 'dbdump.xml';
     $dbFilePath = $tmpDir . DIRECTORY_SEPARATOR . $dbFileName;
     Jaws_DB::getInstance()->Dump($dbFilePath);
     $files = array();
     require_once PEAR_PATH . 'File/Archive.php';
     $files[] = File_Archive::read(JAWS_DATA);
     $files[] = File_Archive::read($dbFilePath, $dbFileName);
     File_Archive::extract($files, File_Archive::toArchive($pathArchive, File_Archive::toFiles()));
     Jaws_Utils::Delete($dbFilePath);
     // browser must download file from server instead of cache
     header("Expires: 0");
     header("Pragma: public");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     // force download dialog
     header("Content-Type: application/force-download");
     // set data type, size and filename
     header("Content-Disposition: attachment; filename=\"{$nameArchive}\"");
     header("Content-Transfer-Encoding: binary");
     header('Content-Length: ' . @filesize($pathArchive));
     @readfile($pathArchive);
     Jaws_Utils::Delete($pathArchive);
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:36,代码来源:Backup.php

示例10: Execute

 /**
  * Returns an array with the results of a search
  *
  * @access  public
  * @param   string  $pSql  Prepared search (WHERE) SQL
  * @return  array   An array of entries that matches a certain pattern
  */
 function Execute($pSql = '')
 {
     $sql = '
         SELECT
             [id], [title], [url], [description], [updatetime]
         FROM [[linkdump_links]]
         ';
     $sql .= ' WHERE ' . $pSql;
     $sql .= ' ORDER BY [createtime] desc';
     $result = Jaws_DB::getInstance()->queryAll($sql);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $links = array();
     foreach ($result as $r) {
         $link = array();
         $link['title'] = $r['title'];
         $link['url'] = $this->gadget->urlMap('Link', array('id' => $r['id']));
         $link['outer'] = true;
         $link['image'] = 'gadgets/LinkDump/Resources/images/logo.png';
         $link['snippet'] = $r['description'];
         $link['date'] = $date->ToISO($r['updatetime']);
         $links[] = $link;
     }
     return $links;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:34,代码来源:Search.php

示例11: InsertContact

 /**
  * Sends email to user
  *
  * @access  public
  * @param   string  $name       Name
  * @param   string  $email      Email address
  * @param   string  $company
  * @param   string  $url
  * @param   string  $tel
  * @param   string  $fax
  * @param   string  $mobile
  * @param   string  $address
  * @param   string  $rcipient   Rcipient ID
  * @param   string  $subject    Subject of message
  * @param   string  $attachment Attachment filename
  * @param   string  $message    Message content
  * @return  bool    True on Success or False on Failure
  */
 function InsertContact($name, $email, $company, $url, $tel, $fax, $mobile, $address, $recipient, $subject, $attachment, $message)
 {
     $now = Jaws_DB::getInstance()->date();
     $data = array();
     $data['[user]'] = $GLOBALS['app']->Session->GetAttribute('user');
     $data['ip'] = $_SERVER['REMOTE_ADDR'];
     $data['name'] = $name;
     $data['email'] = $email;
     $data['company'] = $company;
     $data['url'] = $url;
     $data['tel'] = $tel;
     $data['fax'] = $fax;
     $data['mobile'] = $mobile;
     $data['address'] = $address;
     $data['recipient'] = (int) $recipient;
     $data['subject'] = $subject;
     $data['attachment'] = $attachment;
     $data['msg_txt'] = $message;
     $data['reply'] = '';
     $data['reply_sent'] = 0;
     $data['createtime'] = $now;
     $data['updatetime'] = $now;
     $cntctTable = Jaws_ORM::getInstance()->table('contacts');
     $result = $cntctTable->insert($data)->exec();
     if (Jaws_Error::IsError($result)) {
         return false;
     }
     $GLOBALS['app']->Session->SetCookie('visitor_name', $name, 60 * 24 * 150);
     $GLOBALS['app']->Session->SetCookie('visitor_email', $email, 60 * 24 * 150);
     $GLOBALS['app']->Session->SetCookie('visitor_url', $url, 60 * 24 * 150);
     return $result;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:50,代码来源:Contacts.php

示例12: Execute

 /**
  * Returns an array of the search results
  *
  * @access  public
  * @param   string  $pSql  Prepared search(WHERE) SQL
  * @return  array   Array of entries match a certain pattern
  */
 function Execute($pSql = '')
 {
     $sql = '
         SELECT
             [id], [title], [quotation], [updatetime]
         FROM [[quotes]]
         WHERE [published] = {published}
         ';
     $sql .= ' AND ' . $pSql;
     $sql .= ' ORDER BY [id] desc';
     $params = array();
     $params['published'] = true;
     $result = Jaws_DB::getInstance()->queryAll($sql, $params);
     if (Jaws_Error::IsError($result)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $quotations = array();
     foreach ($result as $r) {
         $quotation = array();
         $quotation['title'] = $r['title'];
         $quotation['url'] = $this->gadget->urlMap('ViewQuote', array('id' => $r['id']));
         $quotation['image'] = 'gadgets/Quotes/Resources/images/logo.png';
         $quotation['snippet'] = $r['quotation'];
         $quotation['date'] = $date->ToISO($r['updatetime']);
         $quotations[] = $quotation;
     }
     return $quotations;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:36,代码来源:Search.php

示例13: UpdateCategory

 /**
  * Updates a category entry
  *
  * @access  public
  * @param   int     $cid            Category ID
  * @param   string  $name           Category name
  * @param   string  $description    Category description
  * @param   string  $fast_url       Category fast url
  * @param   string  $meta_keywords  Meta keywords of the category
  * @param   string  $meta_desc      Meta description of the category
  * @return  mixed   True on success, Jaws_Error on failure
  */
 function UpdateCategory($cid, $name, $description, $fast_url, $meta_keywords, $meta_desc)
 {
     if (!$this->gadget->GetPermission('CategoryManage', $cid)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_ACCESS_DENIED'), RESPONSE_ERROR);
         return false;
     }
     $fast_url = empty($fast_url) ? $name : $fast_url;
     $fast_url = $this->GetRealFastUrl($fast_url, 'blog_category', false);
     $params['name'] = $name;
     $params['description'] = $description;
     $params['fast_url'] = $fast_url;
     $params['meta_keywords'] = $meta_keywords;
     $params['meta_description'] = $meta_desc;
     $params['updatetime'] = Jaws_DB::getInstance()->date();
     $catTable = Jaws_ORM::getInstance()->table('blog_category');
     $result = $catTable->update($params)->where('id', $cid)->exec();
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('BLOG_ERROR_CATEGORY_NOT_UPDATED'), RESPONSE_ERROR);
         return new Jaws_Error(_t('BLOG_ERROR_CATEGORY_NOT_UPDATED'));
     }
     if ($this->gadget->registry->fetch('generate_category_xml') == 'true') {
         $model = $this->gadget->model->load('Feeds');
         $catAtom = $model->GetCategoryAtomStruct($cid);
         $model->MakeCategoryAtom($cid, $catAtom, true);
         $model->MakeCategoryRSS($cid, $catAtom, true);
     }
     $GLOBALS['app']->Session->PushLastResponse(_t('BLOG_CATEGORY_UPDATED'), RESPONSE_NOTICE);
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:41,代码来源:Categories.php

示例14: UpdateQuestion

 /**
  * Update a question
  *
  * @access  public
  * @param   string  $id         Number of the question
  * @param   array   $data     Question data
  * @return  mixed   True if question is succesfully updated, Jaws_Error if not
  */
 function UpdateQuestion($id, $data)
 {
     $fast_url = empty($data['fast_url']) ? $data['question'] : $data['fast_url'];
     $data['fast_url'] = $this->GetRealFastUrl($fast_url, 'faq');
     $data['updatetime'] = Jaws_DB::getInstance()->date();
     $faqTable = Jaws_ORM::getInstance()->table('faq');
     return $faqTable->update($data)->where('id', $id)->exec();
 }
开发者ID:uda,项目名称:jaws,代码行数:16,代码来源:Question.php

示例15: Uninstall

 /**
  * Uninstalls the gadget
  *
  * @access  public
  * @return  mixed   True on Success or Jaws_Error on Failure
  */
 function Uninstall()
 {
     $result = Jaws_DB::getInstance()->dropTable('filebrowser');
     if (Jaws_Error::IsError($result)) {
         $errMsg = _t('GLOBAL_ERROR_GADGET_NOT_UNINSTALLED', $this->gadget->title);
         return new Jaws_Error($errMsg);
     }
     return true;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:15,代码来源:Installer.php


注:本文中的Jaws_DB::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。