本文整理汇总了PHP中obj::db方法的典型用法代码示例。如果您正苦于以下问题:PHP obj::db方法的具体用法?PHP obj::db怎么用?PHP obj::db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类obj
的用法示例。
在下文中一共展示了obj::db方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_art_translations
function edit_art_translations() {
global $def; global $check;
if ($check->num(query::$post['id']) && query::$post['type'] == 'art') {
$time = microtime(true)*1000;
$date = obj::transform('text')->rudate();
obj::db()->update('art_translation','active',0,query::$post['id'],'art_id');
if (query::$post['size'] == 'resized') {
$info = obj::db()->sql('select resized, md5 from art where id='.query::$post['id'],1);
$full_size = explode('x',$info['resized']);
$small_size = getimagesize(ROOT_DIR.SL.'images/booru/resized/'.$info['md5'].'.jpg');
$coeff = $full_size[0] / $small_size[0];
} else {
$coeff = 1;
}
foreach (query::$post['trans'] as $key => $translation) {
if (!$text = obj::transform('text')->format($translation['text']))
unset (query::$post['trans'][$key]);
else {
foreach ($translation as $key2 => $one) if ($key2 != 'text') query::$post['trans'][$key][$key2] = round(intval($one) * $coeff);
query::$post['trans'][$key]['pretty_text'] = $translation['text']; query::$post['trans'][$key]['text'] = $text;
}
}
obj::db()->insert('art_translation',array(query::$post['id'],base64_encode(serialize(query::$post['trans'])),query::$post['author'],$date,$time,1));
obj::db()->sql('update art set translator="'.query::$post['author'].'" where id='.query::$post['id'].' and translator=""',0);
}
}
示例2: inner_set
function inner_set($field,$value,$allow_empty = true) {
$parts = explode('.',$field);
$settings = obj::db()->sql('select data from settings where cookie = "'.query::$cookie.'"',2);
$settings = unserialize(base64_decode($settings));
if ($allow_empty || !empty($settings)) {
$settings[$parts[0]][$parts[1]] = $value;
obj::db()->update('settings',array('data'),array(base64_encode(serialize($settings))),query::$cookie,'cookie');
}
}
示例3: get_comments
function get_comments($limit, $area) {
global $error; global $def;
$return = obj::db()->sql('select place, post_id from comment where (area != "deleted"'.$area.') group by place, post_id order by max(sortdate) desc limit '.$limit);
if (is_array($return)) {
$select = array(
$def['type'][0] => "id, comment_count, title, last_comment",
$def['type'][1] => "id, comment_count, title, id as image, last_comment",
$def['type'][2] => "id, comment_count, id as title, thumb as image, last_comment",
"orders" => "id, comment_count, title, email as image, last_comment",
"news" => "id, comment_count, title, image, last_comment"
);
foreach ($return as $one) {
$queries[$one['place']] .= '" or id="'.$one['post_id'];
$comment_query .= ' or (post_id="'.$one['post_id'].'" and place="'.$one['place'].'")';
}
$return = array();
foreach ($queries as $key => $query) {
if ($_comments = obj::db()->sql('select '.$select[$key].', "'.$key.'" as "place" from '.$key.' where ('.substr($query,5).'")','last_comment')) {
$return = $return + $_comments;
}
}
krsort($return);
$comments = obj::db()->sql('select * from comment where (('.substr($comment_query,4).') and area != "deleted") order by sortdate');
foreach ($return as &$one) {
foreach ($comments as $comment)
if ($comment['post_id'] == $one['id'] && $comment['place'] == $one['place'])
$one['comments'][] = $comment;
switch ($one['place']) {
case $def['type'][0]:
$image = Database::order('order', 'asc')
->get_field('post_image', 'file', 'post_id = ?', $one['id']);
$one['image'] = '/images/post/thumb/'.$image.'.jpg';
break;
case $def['type'][1]:
$one['image'] = 'http://www.gravatar.com/avatar/'.md5(strtolower($one['image'])).'?s=100&d=identicon&r=G';
$one['title'] = "Видео: ".$one['title'];
break;
case $def['type'][2]:
$one['image'] = '/images/booru/thumbs/'.$one['image'].'.jpg';
$one['title'] = "Изображение №".$one['title'];
break;
case "orders":
$one['image'] = 'http://www.gravatar.com/avatar/'.md5(strtolower($one['image'])).'?s=100&d=identicon&r=G';
$one['title'] = "Заказ: ".$one['title'];
break;
case "news":
$one['image'] = '/images/news/thumb/'.$one['image'].'.jpg';
break;
}
}
return $return;
}
else $error = true;
}
示例4: replay_add
function replay_add() {
if (query::$post['file']) {
$file = current(query::$post['file']);
obj::db()->insert('_atai_replays',array(
$file['folder'].'/'.$file['filename'],
query::$post['nickname1'],
query::$post['character1'],
query::$post['nickname2'],
query::$post['character2'],
query::$post['stage']
));
}
}
示例5: get_globals
static function get_globals($get, $post)
{
self::$get = self::clean_globals($get, array());
self::$post = self::clean_globals($post, array());
if (isset($post['remember'])) {
$md5 = md5(serialize($post));
if (obj::db()->sql('select id from input_filter where md5 = "' . $md5 . '"', 2)) {
unset($post);
} else {
obj::db()->insert('input_filter', array($md5, time()));
}
}
unset($_GET, $_POST);
return array(self::$get, self::$post);
}
示例6: change_link
function change_link() {
global $check;
if ($check->num(query::$post['id'])) {
obj::db()->update('orders','link',query::$post['link'],query::$post['id']);
$data = obj::db()->sql('select email, spam from orders where id='.query::$post['id'],1);
if ($data['spam']) {
if (substr(query::$post['link'],0,1) == '/') query::$post['link'] = 'http://'.$_SERVER['HTTP_HOST'].query::$post['link'];
$this->set_events(query::$post['id'],$data['email']);
$text = 'В вашем заказе на сайте 4отаку.орг, <a href="http://4otaku.org/order/'.$id.'/">http://4otaku.org/order/'.$id.'/</a> добавили ссылку на найденное:<br /><br />
<a href="'.query::$post['link'].'">'.query::$post['link'].'</a>'.$this->unsubscribe($id);
obj::db()->insert('misc',array('mail_notify',0,$data['email'],'',$text,query::$post['id']));
}
else $this->set_events(query::$post['id']);
}
}
示例7: archive_author
function archive_author() {
global $url;
if ($url[2] != 'art') { $title = ' title,'; $return['display'] = array('archive_body'); }
else $return['display'] = array('archive_artbody');
$items = obj::db()->sql('select author,'.$title.' id, comment_count from '.$url[2].' where area="main" order by sortdate');
$return['count'] = count($items).' '.obj::transform('text')->wcase(count($items),$this->wcase[$url[2]][0],$this->wcase[$url[2]][1],$this->wcase[$url[2]][2]);
if (is_array($items)) foreach ($items as $item) {
$authors = explode('|',trim($item['author'],'|'));
foreach ($authors as $author)
if ($url[2] != 'art') $return['archives'][$author][] = $item;
else $return['archives'][$author]++;
}
$return['name'] = obj::db()->sql('select alias,name from author','alias');
return $return;
}
示例8: action
function action($action,$id) {
if ($id) {
if ($action == 'prolong') {
$data = obj::db()->sql('select email,spam from orders where id='.$id,1);
$action = new input__common();
if ($data['spam']) $action->set_events($id,$data['email']);
else $action->set_events($id);
$this->add_res('Заказ успешно продлен');
}
elseif ($action == 'unsubscribe') {
obj::db()->update('orders','spam',0,$id);
obj::db()->sql('delete from misc where (type="mail_notify" and data5="'.$id.'")',0);
$this->add_res('Вы отписались от уведомлений по заказу <a href="/order/'.$id.'/">http://4otaku.org/order/'.$id.'/</a>');
}
}
else {
$this->add_res('Ошибка, неправильный URL', true);
}
}
示例9: author
function author($authors){
foreach ($authors as &$author) {
$author = preg_replace('/#.*$/','',$author);
if ($check = obj::db()->sql('select alias from author where name = "'.$author.'" or alias="'.$author.'"',2))
$author = $check;
else {
$alias = $this->make_alias($author);
obj::db()->insert('author',array($alias,$author));
$author = $alias;
}
}
return '|'.implode('|',$authors).'|';
}
示例10: track_similar_pictures
function track_similar_pictures() {
if (
!function_exists('puzzle_fill_cvec_from_file') ||
!function_exists('puzzle_vector_normalized_distance') ||
!function_exists('puzzle_compress_cvec') ||
!function_exists('puzzle_uncompress_cvec')
) {
return;
}
/*
$max = obj::db()->sql('select max(id) from art_similar',2);
$arts = obj::db()->sql('select id, thumb from art where id > '.($max ? $max : 0).' and area != "deleted" order by id limit 2000');
foreach ($arts as $art) {
$image = ROOT_DIR.SL.'images'.SL.'booru'.SL.'thumbs'.SL.'large_'.$art['thumb'].'.jpg';
$vector = puzzle_fill_cvec_from_file($image);
$vector = base64_encode(puzzle_compress_cvec($vector));
obj::db()->insert('art_similar',array($art['id'], $vector, 0, ''),false);
}
*/
$all = obj::db()->sql('select id, vector from art_similar where vector != ""','id');
$arts = obj::db()->sql('select * from art_similar where vector != "" and checked=0 limit 100','id');
if (is_array($all) && is_array($arts)) {
foreach ($all as $compare_id => $vector) {
$all[$compare_id] = puzzle_uncompress_cvec(base64_decode($vector));
}
foreach ($arts as $id => $art) {
$art['vector'] = puzzle_uncompress_cvec(base64_decode($art['vector']));
$similar = '|';
$art_area = false;
foreach ($all as $compare_id => $vector) {
if (
$id != $compare_id &&
puzzle_vector_normalized_distance($art['vector'], $vector) < 0.3
) {
if (empty($art_area)) {
$art_area = Database::get_field('art', 'area', $id);
}
if ($art_area == 'cg' &&
Database::get_field('art', 'area', $compare_id) == 'cg') {
continue;
}
$similar .= $compare_id.'|';
}
}
obj::db()->update('art_similar',array('checked','similar'),array(1,$similar),$id);
}
}
}
示例11: search_tags
static function search_tags($query, $current, $step) {
$locate = redo_safety(urldecode($query));
$tags = obj::db()->sql('select * from tag where locate("'.$locate.'",alias) or locate("'.$locate.'",variants) or locate("'.$locate.'",name) order by id desc limit '.(($current-1)*$step).', '.$step,'id');
$page_count = ceil(obj::db()->sql('select count(id) from tag where locate("'.$locate.'",alias) or locate("'.$locate.'",variants) or locate("'.$locate.'",name)',2)/$step);
return array($tags, $page_count);
}
示例12: title_news
function title_news() {
global $url;
if ($url[2])
return $this->def['site']['short_name'] . ' '.obj::db()->sql('select title from news where url="'.$url[2].'"',2);
else
return $this->def['site']['name'];
}
示例13: add_content
protected function add_content($content, $id) {
$i = 0;
foreach ($content as $type => $items) {
foreach ($items as $item) {
obj::db()->insert('board_attachment',
array($id,$type,base64_encode(serialize($item)),$i++)
);
}
}
}
示例14: masstag
function masstag() {
return obj::db()->sql('select alias, name from category where locate("|art|",area) order by id','alias');
}
示例15: fetch_comment
function fetch_comment($id) {
$item = obj::db()->sql('select * from comment where id='.$id.' limit 1',1);
if ($item['place'] == 'news') {
$item['title'] = 'Комментарий к новости "'.
obj::db()->sql('select title from '.$item['place'].' where url="'.$item['post_id'].'"',2).
'"';
} elseif ($item['place'] == 'art') {
$item['title'] = 'Комментарий к изображению';
$item['preview_picture'] = obj::db()->sql('select thumb from art where id='.$item['post_id'],2);
} else {
$item['title'] = 'Комментарий к '.
$this->comment_titles[$item['place']].' "'.
obj::db()->sql('select title from '.$item['place'].' where id='.$item['post_id'],2).
'"';
}
if ($item['place'] == 'orders') {
$item['place'] = 'order';
}
$item['template'] = 'comment';
return $item;
}