本文整理汇总了PHP中PMF_Db类的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Db类的具体用法?PHP PMF_Db怎么用?PHP PMF_Db使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PMF_Db类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllRelatedById
/**
* Returns all relevant articles for a FAQ record with the same language
*
* @param integer $record_id FAQ ID
* @param string $thema FAQ title
*
* @return string
*/
public function getAllRelatedById($record_id, $article_name, $keywords)
{
global $sids;
$relevantslisting = '';
$begriffe = str_replace('-', ' ', $article_name) . $keywords;
$search = PMF_Search_Factory::create($this->language, array('database' => PMF_Db::getType()));
$i = $last_id = 0;
$search->setDatabaseHandle($this->db)->setTable(SQLPREFIX . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS thema', 'fd.content AS content'))->setJoinedTable(SQLPREFIX . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->language->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
$result = $search->search($begriffe);
while (($row = $this->db->fetchObject($result)) && $i < PMF_Configuration::getInstance()->get('records.numberOfRelatedArticles')) {
if ($row->id == $record_id || $row->id == $last_id) {
continue;
}
$relevantslisting .= '' == $relevantslisting ? '<ul>' : '';
$relevantslisting .= '<li>';
$url = sprintf('%saction=artikel&cat=%d&id=%d&artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
$oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
$oLink->itemTitle = $row->thema;
$oLink->text = $row->thema;
$oLink->tooltip = $row->thema;
$relevantslisting .= $oLink->toHtmlAnchor() . '</li>';
$i++;
$last_id = $row->id;
}
$relevantslisting .= $i > 0 ? '</ul>' : '';
return '' == $relevantslisting ? '-' : $relevantslisting;
}
示例2: __construct
/**
* Constructor
*
*/
public function __construct()
{
global $PMF_LANG;
$this->db = PMF_Db::getInstance();
$this->language = PMF_Language::$language;
$this->pmf_lang = $PMF_LANG;
}
示例3: getAllRelatedById
/**
* Returns all relevant articles for a FAQ record with the same language
*
* @param integer $recordId FAQ ID
* @param string $question FAQ title
* @param string $keywords FAQ keywords
*
* @return array
*/
public function getAllRelatedById($recordId, $question, $keywords)
{
$terms = str_replace('-', ' ', $question) . $keywords;
$search = PMF_Search_Factory::create($this->_config, array('database' => PMF_Db::getType()));
$search->setTable(PMF_Db::getTablePrefix() . 'faqdata AS fd')->setResultColumns(array('fd.id AS id', 'fd.lang AS lang', 'fcr.category_id AS category_id', 'fd.thema AS question', 'fd.content AS answer'))->setJoinedTable(PMF_Db::getTablePrefix() . 'faqcategoryrelations AS fcr')->setJoinedColumns(array('fd.id = fcr.record_id', 'fd.lang = fcr.record_lang'))->setConditions(array('fd.active' => "'yes'", 'fd.lang' => "'" . $this->_config->getLanguage()->getLanguage() . "'"))->setMatchingColumns(array('fd.thema', 'fd.content', 'fd.keywords'));
$result = $search->search($terms);
return $this->_config->getDb()->fetchAll($result);
}
示例4: connect
/**
* Connects to the database.
*
* This function connects to a ibase database
*
* @param string $host
* @param string $username
* @param string $password
* @param string $db_name
* @return boolean true, if connected, otherwise false
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2005-04-16
*/
function connect($host, $user, $passwd, $db)
{
$this->conn = ibase_connect($db, $user, $passwd);
if (false == $this->conn) {
PMF_Db::errorPage(ibase_errmsg());
die;
}
return true;
}
示例5: connect
/**
* Connects to the database.
*
* @param string $host
* @param string $username
* @param string $password
* @param string $db_name
* @return boolean TRUE, if connected, otherwise FALSE
*/
function connect($host, $user, $passwd, $db)
{
$this->conn = mssql_pconnect($host, $user, $passwd);
if (empty($db) or $this->conn == false) {
PMF_Db::errorPage(mssql_get_last_message());
die;
}
return mssql_select_db($db, $this->conn);
}
示例6: connect
/**
* Connects to the database.
*
* @param string
* @return boolean
*/
public function connect($host, $user = false, $passwd = false, $db = false)
{
$this->conn = new SQLite3($host);
if (!$this->conn) {
PMF_Db::errorPage($this->conn->lastErrorMsg());
die;
}
return true;
}
示例7: __construct
/**
* Constructor
*
* @param resource$result Resultset
*/
public function __construct($result)
{
$this->db = PMF_Db::getInstance();
$arrayObject = new ArrayObject();
while ($row = $this->db->fetch_assoc($result)) {
$arrayObject[] = $row;
}
$this->iterator = $arrayObject->getIterator();
}
示例8: connect
/**
* Connects to the database.
*
* @param string
* @return boolean
*/
public function connect($host, $user = false, $passwd = false, $db = false)
{
$this->conn = sqlite_open($host, 0666);
if (!$this->conn) {
PMF_Db::errorPage(sqlite_error_string(sqlite_last_error($this->conn)));
die;
}
return true;
}
示例9: connect
/**
* Connects to the database.
*
* This function connects to a MySQL database
*
* @param string $host Hostname
* @param string $username Username
* @param string $password Password
* @param string $db_name Database name
* @return boolean TRUE, if connected, otherwise false
*/
public function connect($host, $user, $password, $db)
{
$this->conn = mysql_connect($host, $user, $password);
if (empty($db) || $this->conn == false) {
PMF_Db::errorPage($this->error());
die;
}
return mysql_select_db($db, $this->conn);
}
示例10: connect
/**
* Connects to the database.
*
* This function connects to a MySQL database
*
* @param string $host
* @param string $username
* @param string $password
* @param string $db_name
* @return boolean TRUE, if connected, otherwise FALSE
* @access public
* @author Adam Greene <phpmyfaq@skippy.fastmail.fm>
* @since 2004-12-10
*/
function connect($host, $user, $passwd, $db)
{
$this->conn = @sybase_pconnect($host, $user, $passwd);
if (empty($db) || $this->conn === false) {
PMF_Db::errorPage('An unspecified error occurred.');
die;
}
return @sybase_select_db($db, $this->conn);
}
示例11: connect
/**
* Connects to the database.
*
* This function connects to a MySQL database
*
* @param string $host
* @param string $username
* @param string $password
* @param string $db_name
* @return boolean true, if connected, otherwise false
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2005-02-21
*/
public function connect($host, $user, $passwd, $db)
{
$this->conn = new mysqli($host, $user, $passwd, $db);
if (mysqli_connect_errno()) {
PMF_Db::errorPage(mysqli_connect_error());
die;
}
return true;
}
示例12: connect
/**
* This function connects to a DB2 database
*
* @param string $host
* @param string $username
* @param string $password
* @param string $db_name
* @return boolean TRUE, if connected, otherwise FALSE
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2005-04-16
*/
function connect($host, $user, $passwd, $db)
{
$this->conn = db2_pconnect($db, $user, $passwd, $this->options);
if (false == $this->conn) {
PMF_Db::errorPage(db2_conn_errormsg());
die;
}
return true;
}
示例13: connect
/**
* Connects to the database.
*
* @param string $host Hostname
* @param string $user Username
* @param string $password Password
* @param string $database Database name
*
* @return boolean true, if connected, otherwise false
*/
public function connect($host, $user, $password, $database = '')
{
try {
$this->conn = new PDO('mysql:host=' . $host . ';dbname=' . $database . ';charset=UTF8', $user, $password);
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
PMF_Db::errorPage('Database connection failed: ' . $e->getMessage());
}
return true;
}
示例14: getBreadcrumbs
/**
* Get an array with minimalistic attachment meta data
*
* @return array
*/
public function getBreadcrumbs()
{
$retval = array();
$query = sprintf("\n SELECT\n fa.id AS ID,\n fa.record_id AS record_id,\n fa.record_lang AS record_lang,\n fa.filename AS filename,\n fa.filesize AS filesize,\n fa.mime_type AS mime_type,\n fd.thema AS thema\n FROM\n %s fa\n JOIN\n %s fd\n ON\n fa.record_id = fd.id\n GROUP BY\n fa.id", PMF_Db::getTablePrefix() . 'faqattachment', PMF_Db::getTablePrefix() . 'faqdata');
$result = $this->config->getDb()->query($query);
if ($result) {
$retval = $this->config->getDb()->fetchAll($result);
}
return $retval;
}
示例15: connect
/**
* Connects to the database.
*
* @param string $host
* @param string $username
* @param string $password
* @param string $db_name
* @return boolean TRUE, if connected, otherwise FALSE
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @since 2005-09-20
*/
public function connect($host, $user, $passwd, $db)
{
$this->conn = oci_connect($user, $passwd, $db);
if (empty($db) or $this->conn == true) {
$error = oci_error();
PMF_Db::errorPage($error['message']);
return false;
}
return true;
}