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


PHP Writer::main方法代码示例

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


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

示例1: json_encode

<?php

require '../../php/main/db_connect.php';
require '../mm/parser.php';
$id_last = filter_input(INPUT_GET, 'last_id', FILTER_VALIDATE_INT);
$id_dialog = filter_input(INPUT_GET, 'page');
$arr = array();
if ($user_id && $id_last && $id_dialog) {
    $x = $o->getOne("SELECT mes_id FROM users_messages WHERE d_id=?i ORDER BY mes_id DESC LIMIT 1", $id_dialog);
    $y = $o->getOne("SELECT d_id FROM users_dialogs WHERE d_id=?i AND pioneer_id=?i OR d_id=?i AND other_id=?i LIMIT 1", $id_dialog, $user_id, $id_dialog, $user_id);
    if ($x !== $id_last && $y) {
        $writer = new Writer();
        $query = $o->getAll("SELECT m.text, m.date, m.mes_id, m.d_id, i.avatar, i.category, i.nickname FROM users_messages m, users_information i WHERE m.d_id=?i AND m.mes_id>?i AND m.user_id <> ?i AND i.user_id=m.user_id ORDER BY m.mes_id DESC LIMIT 9", $id_dialog, $id_last, $user_id);
        foreach ($query as $array) {
            $image = file_exists('../../upload_image/avatars/pre_150px/' . $array['avatar'] . '.jpg') ? $array['avatar'] : 'default';
            $res = array('dialog_id' => $array['d_id'], 'message_id' => $array['mes_id'], 'date' => $array['date'], 'text' => $writer->main($array['text']), 'avatar' => $image, 'nickname' => $array['nickname']);
            array_push($arr, $res);
        }
    }
}
print json_encode($arr);
开发者ID:alexander-shibisty,项目名称:subscribeonme,代码行数:21,代码来源:message_update.php

示例2: json_encode

<?php

require '../php/main/db_connect.php';
require 'mm/parser.php';
$arr = array();
if ($last_id && $page && $user_id) {
    $string_object = new SafeMySQL();
    $writer = new Writer();
    $y = $string_object->getRow("SELECT d_id, other_id, pioneer_id,meter FROM users_dialogs WHERE d_id=?i AND pioneer_id=?i OR d_id=?i AND other_id=?i LIMIT 1", $category, $user_id, $category, $user_id);
    if ($y['d_id']) {
        $dg = $string_object->getAll("SELECT m.text, m.date, m.mes_id, i.avatar, i.category, i.nickname FROM users_messages m, users_information i WHERE m.d_id=?i AND m.mes_id < ?i AND i.user_id = m.user_id ORDER BY m.mes_id DESC LIMIT 10", $y['d_id'], $last_id);
        $avatar = $string_object->getOne('SELECT avatar FROM users_information WHERE user_id=?i', $user_id);
        $avatar = file_exists('../upload_image/avatars/pre_150px/' . $avatar . '.jpg') ? $avatar : 'default';
        $i = 0;
        foreach ($dg as $array) {
            $res = array('n0' => $y['d_id'], 'n1' => $array['mes_id'], 'n2' => $array['avatar'], 'n3' => $array['nickname'], 'n4' => $array['date'], 'n5' => $writer->main($array['text'], 1));
            $i++;
            array_push($arr, $res);
        }
        unset($array);
    }
}
print json_encode($arr);
开发者ID:alexander-shibisty,项目名称:subscribeonme,代码行数:23,代码来源:str.php

示例3: json_encode

    //$string_object = new SafeMySQL();
    $writer = new Writer();
    $last_id = date('Y-m-d H:i:s', $last_id);
    $query = $o->getAll("SELECT d_id,pioneer_id,other_id,date,meter FROM users_dialogs WHERE pioneer_id=?i AND date<?s OR other_id=?i AND date<?s ORDER BY date DESC LIMIT 0,9", $user_id, $last_id, $user_id, $last_id);
    //Нужно перебрать все d_id в массиве, чтобы передать их в IN() для выборки последних сообщений в диалоге
    $arr_id = array();
    $r = array();
    foreach ($query as $m_id) {
        array_push($arr_id, $m_id['d_id']);
        $u_ids = $user_id === $m_id['pioneer_id'] ? $m_id['other_id'] : $m_id['pioneer_id'];
        array_push($r, $u_ids);
    }
    unset($m_id);
    $x = $o->getAll("SELECT text,user_id FROM (SELECT m.d_id,m.text,m.user_id,i.nickname,i.avatar FROM users_messages m, users_information i WHERE m.d_id IN(?a) AND i.user_id = m.user_id ORDER BY m.mes_id DESC) AS timetable WHERE d_id IN(?a) GROUP BY FIELD(d_id,?a) LIMIT 0,9", $arr_id, $arr_id, $arr_id);
    //Нужно перебрать все id пользователей в массив, чтобы передать в IN и выбрать из базы данные пользователей, с которым ведет переписку клиент, который запрашивает страницу
    //по этому мы отсеиваем ид, если он равен иду этого клиента (клиент ничего не поймет, если увидит у себя диалог с собой же)
    $y = $o->getAll("SELECT i.category, i.avatar, i.nickname,o.online FROM users_information i, users_online o WHERE i.user_id IN(?a) AND o.user_id = i.user_id ORDER BY FIELD(i.user_id,?a) LIMIT 0,9", $r, $r);
    //$cout_el = $string_object->getOne("SELECT COUNT(*) FROM users_dialogs WHERE pioneer_id=?i OR other_id=?i",$user_id,$user_id);
    //Теперь нам нужно все упаковать в json и вернуть
    $i = 0;
    foreach ($query as $array) {
        $image = file_exists('../upload_image/avatars/pre_150px/' . $y[$i]['avatar'] . '.jpg') ? $y[$i]['avatar'] : 'default';
        $mini_image = file_exists('../upload_image/avatars/pre_50px/' . $x[$i]['avatar'] . '.jpg') ? $x[$i]['avatar'] : 'default';
        $read = $array['meter'] !== $user_id && $array['meter'] !== '0' ? '#d1d1d1' : '#000';
        $res = array('n0' => $array['d_id'], 'n1' => $image, 'n2' => $y[$i]['nickname'], 'n3' => $y[$i]['online'], 'n4' => $y[$i]['category'], 'n5' => $array['date'], 'n6' => $x[$i]['text'] ? $writer->main($x[$i]['text']) : ':(', 'n7' => strtotime($array['date']), 'n8' => $read, 'n9' => $x[$i]['nickname'] ? $x[$i]['nickname'] : 'Сообщений нет', 'n10' => $mini_image);
        $i++;
        array_push($arr, $res);
    }
    unset($array);
}
print json_encode($arr);
开发者ID:alexander-shibisty,项目名称:subscribeonme,代码行数:31,代码来源:str.php


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