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


PHP DatabaseConnection::getSingleRow方法代码示例

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


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

示例1: loadWikiPage

 /**
  * @brief Loads a wiki page
  *
  * Will attempt to load a wiki page from the database. If revision is not
  * specified, the latest revision will be loaded.
  *
  * @param String $page
  * @param Int $revision
  * @return Boolean True on success, false otherwise
  */
 function loadWikiPage($page, $revision = null)
 {
     $db = new DatabaseConnection();
     list($ns, $name) = $this->splitUri($page, 'wiki');
     if (!$revision) {
         $pd = $db->getSingleRow("SELECT * FROM wikipages WHERE pagens=%s AND pagename=%s " . "ORDER BY revision DESC LIMIT 1;", $ns, $name);
     } else {
         $pd = $db->getSingleRow("SELECT * FROM wikipages WHERE pagens=%s AND pagename=%s AND " . "revision<%d ORDER BY revision DESC LIMIT 1;", $ns, $name, $revision);
     }
     if ($pd) {
         $revs = $db->getSingleRow("SELECT revision FROM wikipages WHERE pagens=%s AND pagename=%s", $ns, $name);
         foreach ($revs as $rev) {
             $this->revisions[] = $rev['revision'];
         }
         if ($pd['format'] != NULL) {
             $this->markup = $pd['markuptype'];
             $this->parser = markup::factory($this->markup);
         }
         $this->content = $pd['content'];
         $this->pagerevision = $pd['revision'];
         $this->modified = false;
         $this->pagens = $pd['pagens'];
         $this->pagename = $pd['pagename'];
         $this->pagetitle = $pd['pagetitle'];
         return true;
     } else {
         return false;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:39,代码来源:wiki.php

示例2: staticText

 function staticText($slug)
 {
     $db = new DatabaseConnection();
     $text = $db->getSingleRow("SELECT * FROM statictext WHERE slug=%s", $slug);
     if ($text) {
         return $text['content'];
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:8,代码来源:content.php

示例3: __construct

 /**
  * Create a new collection using an uri or a pattern
  *
  * f.ex.  tag:foo, category:bar, title:*, *, user:bob
  *
  */
 public function __construct($selection, Paginator $paginator = null)
 {
     // Create a collection from a tag, category, title, user etc.
     $db = new DatabaseConnection();
     $sql = $db->quote('SELECT * FROM galleryitems');
     $count = $db->quote('SELECT COUNT(*) AS numitems FROM galleryitems');
     // If we have a paginator, make use of it
     if ($paginator) {
         $sql .= ' ' . $paginator->getSqlLimit();
     }
     // Then select the rows and the total count
     $rs = $db->getRows($sql);
     $rsc = $db->getSingleRow($count);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:20,代码来源:gallery.php

示例4: unlinkIdentity

 /**
  * @brief Unlink an identity based on its id.
  *
  * @param int $iid The identity ID
  * @param int $userid The user ID that owns the identity
  * @return boolean True on success
  */
 static function unlinkIdentity($iid, $userid = null)
 {
     $db = new DatabaseConnection();
     // Default to the active user
     if (!$userid) {
         $userid = user::getActiveUser()->userid;
     }
     // And make sure we have an identity to unlink
     if ($iid != 0) {
         $identities = $db->getRows("SELECT * FROM userengage WHERE userid=%d", user::getActiveUser()->userid);
         $identity = $db->getSingleRow("SELECT * FROM userengage WHERE userid=%d AND id=%d", user::getActiveUser()->userid, $iid);
         if (count($identities) > 1) {
             if ($identity) {
                 $db->updateRow("DELETE FROM userengage WHERE userid=%d AND id=%d", user::getActiveUser()->userid, $iid);
                 return true;
             }
         } else {
             view::set('identity', $identity);
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:31,代码来源:engage.php

示例5: checkUsername

 /**
  * @brief Checks to see if a username is available.
  * Keep in mind that if the username is available, true is returned.
  * This is contrary to the find() methods.
  *
  * @see User::find
  * @param string $username The username to check
  * @return bool True if the username is valid, false otherwise
  */
 static function checkUsername($username)
 {
     $db = new DatabaseConnection();
     $record = $db->getSingleRow("SELECT * FROM users WHERE username=%s", $username);
     return $record == null;
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:15,代码来源:user.php

示例6: export

 public function export()
 {
     console::writeLn(__astr('\\b{Exporting tables and data}'));
     $db = new DatabaseConnection();
     $args = func_get_args();
     if (count($args) == 0) {
         $args[] = '%';
     }
     $drop = false;
     $data = false;
     foreach ($args as $arg) {
         try {
             if (strtolower($arg) == 'drop') {
                 $drop = true;
             } elseif (strtolower($arg) == 'data') {
                 $data = true;
             } else {
                 $tbl = $db->getRows("SHOW TABLES LIKE %s", $arg);
                 foreach ($tbl as $tblc) {
                     $c = $tblc[0];
                     console::write("  [app] %-30s ", $c);
                     // Get the create table syntax
                     $crs = $db->getSingleRow("SHOW CREATE TABLE " . $c);
                     $sqlcreate = $crs;
                     // Get the data
                     $fsql = fopen(expandpath('app:/sql/' . $c . '.sql'), 'w');
                     if ($drop) {
                         fputs($fsql, "DROP TABLE IF EXISTS " . $c . ";\n");
                     }
                     fputs($fsql, $crs[1] . "\n");
                     fclose($fsql);
                     console::write("SQL ");
                     if ($data) {
                         // Export the data as well
                         $drs = $db->getRows("SELECT * FROM " . $c);
                         foreach ($drs[0] as $k => $v) {
                             if ($k != '0' && intval($k) == 0) {
                                 $hdr[] = $k;
                             }
                         }
                         $fdat = fopen(expandpath('app:/sql/' . $c . '.csv'), 'w');
                         fputcsv($fdat, $hdr, ";", '"');
                         foreach ($drs as $row) {
                             $dout = array();
                             foreach ($row as $i => $h) {
                                 if ($i != '0' && intval($i) == 0) {
                                     $dout[] = $h;
                                 }
                             }
                             fputcsv($fdat, $dout, ";");
                         }
                         fclose($fdat);
                         console::write("CSV ");
                     }
                     console::writeLn();
                 }
             }
         } catch (DatabaseException $e) {
             console::writeLn();
             console::warn($e->getMessage());
         }
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:63,代码来源:database.php

示例7: loadUser

 /**
  * @brief Load a user record from the database.
  *
  * @param int $userid The user ID
  */
 function loadUser($userid)
 {
     if (is_numeric($userid)) {
         $db = new DatabaseConnection();
         $record = $db->getSingleRow("SELECT a.*,u.*,a.id AS userid FROM " . LEPTON_DB_PREFIX . "users a LEFT JOIN " . LEPTON_DB_PREFIX . "userdata u ON a.id=u.id WHERE a.id=%d", $userid);
         if ($record) {
             $this->assign($record);
         } else {
             throw new UserException("No such user ({$userid})");
         }
     } else {
         throw new BadArgumentException("User ID must be an integer");
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:19,代码来源:userrecord.php

示例8: queryUser

 /**
  * @brief Query and return a user record.
  * This can be used by the authentication providers in a number of ways
  * such as resolving user IDs or using information to look in other
  * tables.
  *
  * @param string $username The username to fetch the record from
  * @return array The user record, or null on failure.
  */
 public function queryUser($username)
 {
     $db = new DatabaseConnection();
     try {
         $userrecord = $db->getSingleRow("SELECT * FROM users WHERE username=%s", $username);
         if ($userrecord) {
             return $userrecord;
         }
         return null;
     } catch (Exception $e) {
         throw $e;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:22,代码来源:nouveaubackend.php

示例9: __set

 /**
  *
  * @param type $key
  * @param type $value 
  */
 public function __set($key, $value)
 {
     switch ($key) {
         case 'amount':
             $this->amount = floatval($value);
         case 'symbol':
             $db = new DatabaseConnection();
             $sym = $db->getSingleRow("SELECT * FROM currencyexchange WHERE symbol=%s", $value);
             if ($sym) {
                 $this->symbol = strtoupper($value);
             } else {
                 throw new CurrencyException("No such symbol: " . $value);
             }
         default:
             throw new BadPropertyException($this, $key);
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:22,代码来源:forex.php

示例10: updatePage

 /**
  * Update a wiki page
  * @param string $pagename The namespace and page name
  * @param string $title The page title
  * @param string $content The page content
  */
 function updatePage($pagename, $title, $content)
 {
     $ns = String::getNamespace('default', $pagename);
     $uri = String::getLocation($pagename);
     $db = new DatabaseConnection();
     $author = User::getActiveUserId();
     try {
         // pull the latest revision of the page
         $rs = $db->getSingleRow('SELECT MAX(revision) AS latest FROM wiki WHERE ns=\'%s\' AND uri=\'%s\'', $ns, $uri);
         $currev = $rs ? $rs['latest'] : 0;
         // set to 0 if no record returned
         // bump revision
         $currev++;
         // and insert the new data
         $db->updateRow("INSERT INTO wiki SET content='%s',revision='%d',title='%s',ns='%s',uri='%s',lastedit=NOW(),author='%d'", $content, $currev, $title, $ns, $uri, $author);
     } catch (DBXException $e) {
         die($e);
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:25,代码来源:wiki.php

示例11: getKeyForUser

 function getKeyForUser($username)
 {
     $user = User::find($username);
     if ($user) {
         $userid = $user->userid;
         $db = new DatabaseConnection();
         $rs = $db->getSingleRow("SELECT * FROM userppp WHERE id=%d", $userid);
         if ($rs) {
             $codekey = $rs['secretkey'];
         } else {
             $codekey = null;
         }
         return $codekey;
     } else {
         throw new UserException('User not found.');
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:17,代码来源:ppp.php

示例12: updateSets

 private static function updateSets(callback $callback = null)
 {
     // Update the callback if one is present
     if ($callback) {
         $callback->call('Updating sets...');
     }
     // Pull the country list
     $db = new DatabaseConnection();
     $rs = $db->getRows("SELECT isocode,capital FROM geonames_countryinfo");
     foreach ($rs as $cc) {
         $f = $db->getSingleRow("SELECT * FROM geonames_datasets WHERE setkey=%s", $cc['isocode']);
         if (!$f) {
             $db->insertRow("INSERT INTO geonames_datasets (setkey,setname,url,active) VALUES (%s,%s,%s,0)", $cc['isocode'], $cc['capital'], self::getUrl($cc['isocode'] . '.zip'));
         }
     }
     if ($callback) {
         $callback->call('All sets updated');
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:19,代码来源:geonames.php


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