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


PHP Database::sql2row方法代码示例

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


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

示例1: getRightholder

 function getRightholder()
 {
     $id = max(0, (int) $this->params['rightholder_id']);
     $query = 'SELECT * FROM `rightholders` WHERE `id`=' . $id;
     $data = Database::sql2row($query);
     $this->data['partner'] = $data;
 }
开发者ID:rasstroen,项目名称:metro,代码行数:7,代码来源:rightholders_module.php

示例2: getPostsUpdatesLast

 function getPostsUpdatesLast()
 {
     $query = 'SELECT * FROM `posts_updates_last`';
     $data = Database::sql2row($query);
     $data['time'] = date('Y/m/d H:i:s', $data['time']);
     $this->data['snippet'] = $data;
 }
开发者ID:rasstroen,项目名称:sosedi,代码行数:7,代码来源:snippet_module.php

示例3: write

 function write()
 {
     global $current_user;
     /*@var $current_user CurrentUser*/
     $current_user->can_throw('books_edit');
     $id = isset(Request::$post['id']) ? Request::$post['id'] : 0;
     $id = max(0, (int) $id);
     $row = Database::sql2row('SELECT * FROM genre WHERE `id`=' . $id);
     if (!$row) {
         return;
     }
     if (!$id) {
         throw new Exception('Illegal id');
     }
     $description = prepare_review(isset(Request::$post['description']) ? Request::$post['description'] : '');
     if (!$description) {
         throw new Exception('Empty description');
     }
     $description = prepare_review($description);
     $query = 'UPDATE `genre` SET `description`=' . Database::escape($description) . ' WHERE `id`=' . $id;
     Database::query($query);
     ob_end_clean();
     header('Location:' . Config::need('www_path') . '/genres/' . $row['name']);
     $current_user->gainActionPoints('genres_edit', $id, BiberLog::TargetType_genre);
     exit;
 }
开发者ID:rasstroen,项目名称:metro,代码行数:26,代码来源:GenreWriteModule.php

示例4: write

 function write()
 {
     global $current_user;
     /* @var $current_user CurrentUser */
     $mask = array('user_id' => 'int', 'hash' => array('type' => 'string', 'regexp' => '/^[A-Za-z0-9]+$/', 'min_length' => 32, 'max_length' => 32));
     $params = Request::checkParameters(Request::getAllParameters(), $mask);
     // проверяем, есть ли в базе неподтвержденный юзер с таким хешем
     $query = 'SELECT * FROM `users` WHERE `id`=' . (int) $params['user_id'];
     $res = Database::sql2row($query);
     if (!$res || $res['hash'] != $params['hash']) {
         if ($res['hash'] != '') {
             $this->setWriteParameter('emailconfirm_module', 'error', 'Неправильный код подтверждения.');
         } else {
             if ($res['id']) {
                 $this->setWriteParameter('emailconfirm_module', 'error', 'Почта пользователя уже подтверждена');
             } else {
                 $this->setWriteParameter('emailconfirm_module', 'error', 'Такого пользователя не существует');
             }
         }
     } else {
         // ура! авторизуем пользователя
         $current_user->load($res);
         $current_user->setRole(User::ROLE_READER_CONFIRMED);
         $current_user->authorized = true;
         $current_user->onLogin();
         $current_user->save();
         // затираем ему хеш и меняем роль на авторизованного пользователя
         $this->setWriteParameter('emailconfirm_module', 'success', 1);
     }
 }
开发者ID:rasstroen,项目名称:jma,代码行数:30,代码来源:EmailConfirmWriteModule.php

示例5: getMessageNode

 function getMessageNode()
 {
     $messageA = array();
     $node = false;
     if ($r = Request::get('redirect')) {
         list($type, $id) = explode('_', $r);
         switch ($type) {
             case 's':
                 $query = 'SELECT * FROM `series` WHERE `id`=' . (int) $id;
                 $res = Database::sql2row($query);
                 if ($res && isset($res['is_s_duplicate']) && $res['is_s_duplicate']) {
                     $messageA = array('html' => 'Cерия «' . $res['title'] . '» была склеена с данной серией');
                     $node = XMLClass::createNodeFromObject($messageA, false, 'message', true);
                 }
                 break;
             case 'b':
                 $query = 'SELECT * FROM `book` WHERE `id`=' . (int) $id;
                 $book = new Book((int) $id);
                 if ($book->getDuplicateId()) {
                     $messageA = array('html' => 'Книга «' . $book->getTitle(true) . '» была склеена с данной книгой');
                     $node = XMLClass::createNodeFromObject($messageA, false, 'message', true);
                 }
                 break;
             case 'a':
                 $person = new Person((int) $id);
                 if ($person->getDuplicateId()) {
                     $messageA = array('html' => 'Автор «' . $person->getName() . '» был склеен с данным автором');
                     $node = XMLClass::createNodeFromObject($messageA, false, 'message', true);
                 }
                 break;
         }
     }
     return $node;
 }
开发者ID:rasstroen,项目名称:metro,代码行数:34,代码来源:PageConstructor.php

示例6: getOnePost

    function getOnePost()
    {
        $aid = (int) $this->params['user_id'];
        $pid = (int) $this->params['post_id'];
        $query = 'SELECT * FROM `posts_index` WHERE 
			`id_post`=' . $pid . ' AND
			`id_author`=' . $aid;
        $res = Database::sql2row($query);
        if ($res) {
            $res['m'] = str_pad($res['m'], 2, '0', STR_PAD_LEFT);
            $tblname = 'posts_data__' . $res['y'] . '_' . $res['m'];
            try {
                $query = 'SELECT * FROM `' . $tblname . '` WHERE
					`id`=' . $pid . ' AND
					`id_author`=' . $aid;
                $data = Database::sql2row($query);
                if ($data) {
                    $post = new Post($data);
                    $this->data['post'] = $post->getFull();
                    $aid = $post->data['id_author'];
                    $authors = Database::sql2array('SELECT * FROM `authors` WHERE `id` =' . $aid . '');
                    foreach ($authors as $data) {
                        $author = new Author($data);
                        $this->data['authors'][] = $author->getShort();
                    }
                    return true;
                }
            } catch (Exception $e) {
            }
        }
        throw new Exception('Не можем найти такой записи', '404');
    }
开发者ID:rasstroen,项目名称:sosedi,代码行数:32,代码来源:posts_module.php

示例7: getOne

	function getOne() {
		$query = 'SELECT * FROM `genre` WHERE `name`=' . Database::escape($this->genre_name);
		$data = Database::sql2row($query);
		if (!isset($data['name']))
			return;
		$this->data['genres'][$data['id']] = array(
		    'name' => $data['name'],
		    'id' => $data['id'],
		    'id_parent' => $data['id_parent'],
		    'title' => $data['title'],
		    'books_count' => $data['books_count']
		);

		if (!$data['id_parent']) {
			$this->data['genres'][$data['id']]['subgenres'] = $this->getAll($data['id']);
			return;
		}

		$query = 'SELECT `id_book` FROM `book_genre` BG JOIN `book` B ON B.id = BG.id_book WHERE BG.id_genre = ' . $data['id'] . ' ORDER BY B.mark DESC LIMIT 20';
		$bids = Database::sql2array($query, 'id_book');
		$books = Books::getByIdsLoaded(array_keys($bids));
		Books::LoadBookPersons(array_keys($bids));

		foreach ($books as $book) {
			$book = Books::getById($book->id);
			list($aid, $aname) = $book->getAuthor(1, 1, 1); // именно наш автор, если их там много
			$this->data['genres'][$data['id']]['books'][] = array('id' => $book->id,
			    'cover' => $book->getCover(),
			    'title' => $book->getTitle(true),
			    'author' => $aname,
			    'author_id' => $aid,
			    'lastSave' => $book->data['modify_time']);
		}
	}
开发者ID:rasstroen,项目名称:diary,代码行数:34,代码来源:genres_module.php

示例8: getByIdLoaded

 public static function getByIdLoaded($user_id)
 {
     $data = Database::sql2row('SELECT * FROM `user` WHERE `id`=' . $user_id);
     if ($data) {
         return new User($user_id, $data);
     } else {
         return false;
     }
 }
开发者ID:rasstroen,项目名称:baby-album,代码行数:9,代码来源:Users.php

示例9: getLikes

	function getLikes() {
		if (!$this->genre_id)
			return;
		$query = 'SELECT * FROM `genre` WHERE `name`=' . Database::escape($this->genre_id);
		$data = Database::sql2row($query);
		if($data['id']){
			
		}
	}
开发者ID:rasstroen,项目名称:diary,代码行数:9,代码来源:users_module.php

示例10: write

	function write() {
		global $current_user;
		/* @var $current_user CurrentUser */
		if (!$current_user->authorized)
			throw new Exception('Access denied');

		$data = array(
		    'target_id' => max(0, (int) Request::$post['target_id']),
		    'target_type' => max(0, (int) Request::$post['target_type']),
		    'comment' => prepare_review(Request::$post['annotation']),
		    'rate' => min(6, max(0, (int) Request::$post['rate'])) + 1,
		);


		$event = new Event();


		if (!$data['comment']) {
			// inserting rate
			if ($data['rate'] && ($data['target_type'] == 0)) {
				$time = time();
				if ($data['rate'] > 1) {
					$query = 'INSERT INTO `book_rate` SET `id_book`=' . $data['target_id'] . ',`id_user`=' . $current_user->id . ',`rate`=' . ($data['rate'] - 1) . ',`time`=' . $time . ' ON DUPLICATE KEY UPDATE
				`rate`=' . ($data['rate'] - 1) . ',`time`=' . $time . '';
					Database::query($query);
				}
				//recalculating rate
				$query = 'SELECT COUNT(1) as cnt, SUM(`rate`) as rate FROM `book_rate` WHERE `id_book`=' . $data['target_id'];
				$res = Database::sql2row($query);
				$book_mark = round($res['rate'] / $res['cnt'] * 10);
				$query = 'UPDATE `book` SET `mark`=' . $book_mark . ' WHERE `id`=' . $data['target_id'];
				Database::query($query);
				$event->event_BookRateAdd($current_user->id, $data['target_id'], $data['rate'] - 1);
			}
		} else {
			if (!$data['target_id'])
				return;
			$query = 'INSERT INTO `reviews` SET
				`id_target`=' . $data['target_id'] . ',
				`target_type`=' . $data['target_type'] . ',
				`id_user`=' . $current_user->id . ',
				`time`=' . time() . ',
				`comment`=' . Database::escape($data['comment']) . ',
				`rate`=' . ($data['rate'] - 1) . '
					ON DUPLICATE KEY UPDATE
				`time`=' . time() . ',
				`comment`=' . Database::escape($data['comment']) . ',
				`rate`=' . ($data['rate'] - 1) . '';
			Database::query($query);
			//event
			$event->event_BookReviewAdd($current_user->id, $data['target_id'],$data['target_type'], $data['rate'] - 1 , $data['comment']);
		}


		$event->push();
	}
开发者ID:rasstroen,项目名称:diary,代码行数:56,代码来源:ReviewsWriteModule.php

示例11: _edit

 function _edit()
 {
     $id = max(0, (int) (isset($this->params['group_id']) ? $this->params['group_id'] : false));
     if (!$id) {
         throw new Exception('no group id');
     }
     $query = 'SELECT * FROM `feature_groups` WHERE `id`=' . $id;
     $data = Database::sql2row($query);
     $this->data['group'] = $data;
 }
开发者ID:rasstroen,项目名称:hardtechno,代码行数:10,代码来源:groups_module.php

示例12: load

 function load($data = false)
 {
     if ($this->is_loaded()) {
         return $this->data;
     }
     $this->data = Database::sql2row('SELECT * FROM `user` WHERE `id`=' . $this->id);
     if ($this->data) {
         $this->registered = true;
     }
     $this->loaded = true;
 }
开发者ID:rasstroen,项目名称:vkontakte,代码行数:11,代码来源:User.php

示例13: getTheme

 function getTheme()
 {
     if (!$this->theme_id) {
         return;
     }
     $query = 'SELECT uid as user_id,title,body FROM `node_revisions` WHERE `nid`=' . $this->theme_id . ' LIMIT 1';
     $theme = Database::sql2row($query);
     if (!$theme) {
         throw new Exception('Мы проебали эту тему форума');
     }
     $theme['body'] = _bbcode_filter_process($theme['body']);
     $this->data['theme'] = $theme;
     Request::pass('theme-title', $theme['title']);
     $cond = new Conditions();
     $per_page = 0;
     if (isset($this->params['per_page'])) {
         $per_page = (int) $this->params['per_page'];
     }
     $per_page = $per_page > 0 ? $per_page : 5;
     $query = 'SELECT pid=0 as pid, COUNT(1) as cnt FROM `comments_v2` WHERE `nid` = ' . $this->theme_id . ' GROUP BY (pid=0)';
     $count_arr = Database::sql2array($query, 'pid');
     $count = isset($count_arr[0]['cnt']) ? $count_arr[0]['cnt'] : 0;
     $count_arr[0] = array('cnt' => $count);
     $count_with_answers = isset($count_arr[1]['cnt']) ? $count_arr[1]['cnt'] + $count_arr[0]['cnt'] : $count_arr[0]['cnt'];
     $cond->setPaging($count, $per_page);
     $limit = $cond->getLimit();
     $query = 'SELECT rid,cid,pid,subject,comment,timestamp,uid FROM `comments_v2` WHERE `nid` = ' . $this->theme_id . ' AND `pid`=0 ORDER BY `timestamp` LIMIT ' . $limit;
     $comments = Database::sql2array($query, 'cid');
     // childs?
     if (count($comments)) {
         $query = 'SELECT * FROM `comments_v2` WHERE `pid` IN(' . implode(',', array_keys($comments)) . ') ORDER BY `sort`';
         $answers = Database::sql2array($query, 'cid');
         foreach ($answers as &$answer) {
             $answer['comment'] = _bbcode_filter_process($answer['comment']);
             $answer['time'] = date('Y/m/d H:i', $answer['timestamp']);
             $comments[$answer['pid']]['answers'][] = $answer;
         }
     }
     $uids = array();
     foreach ($comments as &$comment) {
         $uids[$comment['uid']] = $comment['uid'];
         $comment['comment'] = _bbcode_filter_process($comment['comment']);
         $comment['time'] = date('Y/m/d H:i', $comment['timestamp']);
     }
     $uids[$theme['user_id']] = $theme['user_id'];
     $this->data['theme']['users'] = $this->getUsers($uids);
     $this->data['theme']['tid'] = $this->forum_id;
     $this->data['theme']['theme_id'] = $this->theme_id;
     $this->data['theme']['comments'] = $comments;
     $this->data['theme']['comments']['count'] = $count_with_answers;
     $this->data['theme']['comments']['count_nop'] = $count;
     $this->data['conditions'] = $cond->getConditions();
 }
开发者ID:rasstroen,项目名称:metro,代码行数:53,代码来源:forum_module.php

示例14: load

 function load($data = false)
 {
     if ($this->loaded) {
         return false;
     }
     if (!$data) {
         $query = 'SELECT * FROM `news` WHERE `id`=' . $this->id;
         $this->data = Database::sql2row($query);
     } else {
         $this->data = $data;
     }
     $this->exists = true;
     $this->loaded = true;
 }
开发者ID:rasstroen,项目名称:hardtechno,代码行数:14,代码来源:Newsitem.php

示例15: load

    public function load()
    {
        if ($this->loaded) {
            return;
        }
        $query = 'SELECT * FROM `magazines` M LEFT JOIN `book_magazines` BM 
			ON BM.id_magazine=M.id WHERE M.`id`=' . $this->id;
        $this->data = Database::sql2row($query);
        $query = 'SELECT * FROM `book_magazines` WHERE `id_magazine`=' . $this->id;
        $books = Database::sql2array($query, 'id_book');
        foreach ($books as $row) {
            $this->books[$row['year']][$row['n']] = $row['id_book'];
        }
        $this->loaded = true;
    }
开发者ID:rasstroen,项目名称:metro,代码行数:15,代码来源:Magazine.php


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