query() public static method

public static query ( )
示例#1
1
 public function testInstall()
 {
     global $DB;
     $query = "SHOW FULL TABLES WHERE TABLE_TYPE LIKE 'VIEW'";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $DB->query("DROP VIEW " . $data[0]);
     }
     $query = "SHOW TABLES";
     $result = $DB->query($query);
     while ($data = $DB->fetch_array($result)) {
         $DB->query("DROP TABLE " . $data[0]);
     }
     include_once GLPI_ROOT . "/inc/dbmysql.class.php";
     include_once GLPI_CONFIG_DIR . "/config_db.php";
     // Install a fresh 0.80.5 DB
     $DB = new DB();
     $res = $DB->runFile(GLPI_ROOT . "/install/mysql/glpi-0.80.3-empty.sql");
     $this->assertTrue($res, "Fail: SQL Error during install");
     // update default language
     $query = "UPDATE `glpi_configs`\n                SET `language` = 'en_GB'";
     $this->assertTrue($DB->query($query), "Fail: can't set default language");
     $query = "UPDATE `glpi_users`\n                SET `language` = 'en_GB'";
     $this->assertTrue($DB->query($query), "Fail: can't set users language");
     $GLPIlog = new GLPIlogs();
     $GLPIlog->testSQLlogs();
     $GLPIlog->testPHPlogs();
 }
示例#2
1
 function insert()
 {
     $dbc = new DB();
     $dbc->connect();
     $sql = "insert into registered_users(FullName,Username,Password,Email,Mobile,RegNo) values('{$this->name}','{$this->username}','{$this->password}','{$this->email}','{$this->mobile}','{$this->regNo}')";
     $dbc->query($sql);
 }
示例#3
0
function verifyUser($email, $code, $DATABASE)
{
    $db = new DB();
    $exists = $db->select("SELECT * \n\t                         FROM " . $DATABASE . ".users \n\t                         WHERE email = " . $db->quote($email) . " AND activation = " . $db->quote($code));
    if (empty($exists[0])) {
        error("Invalid Verification", "Your verification is invalid. You might already be verified.");
    } else {
        //TODO this is copied into preferences for updateing email
        if (preg_match("/((@uw\\.edu)|(@u\\.washington\\.edu))/i", $exists[0]["email"])) {
            $netid = substr($exists[0]["email"], 0, strpos($exists[0]["email"], "@"));
            $db->query("UPDATE " . $DATABASE . ".users\n\t\t\t              SET activation = '1', netid = " . $db->quote($netid) . " WHERE email = " . $db->quote($email));
        } else {
            $db->query("UPDATE " . $DATABASE . ".users\n\t\t\t              SET activation = '1', netid = NULL\n\t\t\t              WHERE email = " . $db->quote($email));
        }
        head();
        ?>
		<section class="content">
			<div class="container">
				<h1>Success!</h1>
				<p>You are now verified with the Experimental College! 
				Sign up for some classes!</p>
			</div>
		</section>
		<?php 
        tail();
    }
}
示例#4
0
 function torrents()
 {
     $db = new DB();
     // Remove inactive peers
     $db->query("DELETE FROM {PREFIX}peers WHERE peer_last_action < " . $this->deadtime_peers);
     $db->query("UPDATE {PREFIX}torrents SET torrent_visible='0' WHERE torrent_visible='1' AND torrent_last_action < " . $this->deadtime_peers);
     $db->query("DELETE FROM {PREFIX}users WHERE user_last_access < " . $this->deadtime_users . " AND user_status != 1");
     $torrents = array();
     $db = new DB();
     $db->query("SELECT peer_torrent, peer_seeder, COUNT(*) AS c FROM {PREFIX}peers GROUP BY peer_torrent, peer_seeder");
     while ($db->nextRecord()) {
         if ($db->peer_seeder == 1) {
             $key = "seeders";
         } else {
             $key = "leechers";
         }
         $torrents[$db->peer_torrent][$key] = $db->c;
     }
     foreach ($torrents as $torrent => $array) {
         $update = array();
         if (isset($array['seeders'])) {
             $update[] = "torrent_seeders = " . $array['seeders'];
         }
         if (isset($array['leechers'])) {
             $update[] = "torrent_leechers = " . $array['leechers'];
         }
         $db->query("UPDATE {PREFIX}torrents SET " . implode(", ", $update) . " WHERE torrent_id = '" . $torrent . "'");
     }
 }
示例#5
0
 /**
  * Matriz de permisos - perfiles
  * @return string html
  */
 public function getMatrizPermisos()
 {
     $dataop = "";
     $db = new DB();
     $sql = "SELECT * FROM perfiles";
     $perfiles = $db->query($sql);
     $sql = "SELECT * FROM opciones";
     $opciones = $db->query($sql);
     /* Cadena con encabezado de opciones (componentes)  */
     while ($row = $db->fetchNextObject($opciones)) {
         $dataop .= "<th>{$row->descrip}</th>";
     }
     $data = "<table class='adminlist'>";
     $data .= "<tr><th></th>" . $dataop . "</tr>";
     while ($line = $db->fetchNextObject($perfiles)) {
         $data .= "<tr><td class='headlines'>" . $line->descrip . "</td>";
         /* Trae de nuevo consulta de opciones para construir */
         $opciones = $db->query($sql);
         while ($row = $db->fetchNextObject($opciones)) {
             $sql1 = "SELECT perfil_cd, opcion_cd, lectura, escritura " . "FROM permisos WHERE perfil_cd = {$line->codigo} " . "AND opcion_cd = {$row->codigo}";
             $res = $db->queryUniqueObject($sql1);
             $data .= '<td>Lectura: <input type="checkbox" id="" name="" value="" />';
             $data .= 'Escritura: <input type="checkbox" id="" name="" value="" /></td>';
         }
         $data .= "</tr>";
     }
     $data .= "</table>";
     $tpl = new Erudio_Smarty();
     $tpl->assign('matriz', $data);
     $tpl->display('usuarios/matrizPermisos.tpl');
 }
示例#6
0
 public function index()
 {
     $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PORT);
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $db->query("REPLACE INTO `" . DB_PREFIX . "setting` SET `config_fraud_status_id` = '1', `config_fraud_score` = '" . (int) $this->request->post['config_fraud_score'] . "', `config_fraud_key` = '" . $db->escape($this->request->post['config_fraud_score']) . "', `config_fraud_detection` = '" . (int) $this->request->post['config_fraud_detection'] . "' WHERE `store_id` = '0' AND `code` = 'config'");
         $this->session->data['success'] = $this->language->get('text_maxmind_success');
         $this->response->redirect($this->url->link('step_4'));
     } else {
         $this->document->setTitle($this->language->get('heading_maxmind'));
         $data['heading_maxmind'] = $this->language->get('heading_maxmind');
         $data['heading_maxmind_small'] = $this->language->get('heading_maxmind_small');
         $data['text_maxmind_top'] = $this->language->get('text_maxmind_top');
         $data['text_maxmind_link'] = $this->language->get('text_maxmind_link');
         $data['entry_licence_key'] = $this->language->get('entry_licence_key');
         $data['entry_risk'] = $this->language->get('entry_risk');
         $data['entry_fraud_status'] = $this->language->get('entry_fraud_status');
         $data['help_maxmind_risk'] = $this->language->get('help_maxmind_risk');
         $data['help_maxmind_fraud'] = $this->language->get('help_maxmind_fraud');
         $data['button_continue'] = $this->language->get('button_continue');
         $data['button_back'] = $this->language->get('button_back');
         $data['action'] = $this->url->link('maxmind');
         if (isset($this->request->post['config_fraud_detection'])) {
             $data['config_fraud_detection'] = $this->request->post['config_fraud_detection'];
         } else {
             $data['config_fraud_detection'] = '';
         }
         if (isset($this->request->post['config_fraud_key'])) {
             $data['config_fraud_key'] = $this->request->post['config_fraud_key'];
         } else {
             $data['config_fraud_key'] = '';
         }
         if (isset($this->request->post['config_fraud_score'])) {
             $data['config_fraud_score'] = $this->request->post['config_fraud_score'];
         } else {
             $data['config_fraud_score'] = '80';
         }
         $data['order_statuses'] = $db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE language_id = '1'  ORDER BY name ASC")->rows;
         if (isset($this->request->post['config_fraud_status_id'])) {
             $data['config_fraud_status_id'] = $this->request->post['config_fraud_status_id'];
         } else {
             $data['config_fraud_status_id'] = '';
         }
         if (isset($this->error['fraud_key'])) {
             $data['error_fraud_key'] = $this->error['fraud_key'];
         } else {
             $data['error_fraud_key'] = '';
         }
         if (isset($this->error['fraud_score'])) {
             $data['error_fraud_score'] = $this->error['fraud_score'];
         } else {
             $data['error_fraud_score'] = '';
         }
         $data['back'] = $this->url->link('step_4');
         $data['footer'] = $this->load->controller('footer');
         $data['header'] = $this->load->controller('header');
         $this->response->setOutput($this->load->view('maxmind.tpl', $data));
     }
 }
示例#7
0
 public function getUser()
 {
     $sql = "SELECT id, firstname, lastname, password, email, phone, created_at FROM users";
     $this->db->query($sql);
     $users = $this->db->fetch_accoc();
     echo '<pre>';
     print_r($users);
     echo '</pre>';
 }
示例#8
0
文件: Series.php 项目: ras263/lc
 public static function create_new($series_name)
 {
     $db = new DB();
     $query = 'SELECT * FROM cards_series WHERE name ="' . $series_name . '"';
     $res = $db->query($query);
     if (!($row = mysql_fetch_array($res))) {
         $query = 'INSERT INTO  store.cards_series (serial_id , name ) VALUES ( NULL ,  "' . $series_name . '")';
         $db->query($query);
     }
 }
示例#9
0
文件: genres.php 项目: nubzzz/newznab
 public function getGenres($type = '', $activeonly = false)
 {
     $db = new DB();
     if (!empty($type)) {
         $typesql = sprintf(" and genres.type = %d", $type);
     } else {
         $typesql = '';
     }
     if ($activeonly) {
         return $db->query(sprintf("SELECT genres.*  FROM genres INNER JOIN (SELECT DISTINCT genreID FROM musicinfo) X ON X.genreID = genres.ID %s\n\t\t\tUNION\n\t\t\tSELECT genres.*  FROM genres INNER JOIN (SELECT DISTINCT genreID FROM consoleinfo) X ON X.genreID = genres.ID %s\n\t\t\tORDER BY title", $typesql, $typesql));
     } else {
         return $db->query(sprintf("select genres.* from genres where 1 %s order by title", $typesql));
     }
 }
示例#10
0
 static function getMatchScoreList($verses, $club)
 {
     $db = new DB();
     $sql = "SELECT match_id FROM game WHERE verses = '{$verses}' AND match_date= CURDATE()";
     $m_id = $db->query($sql)->fetch(PDO::FETCH_ASSOC);
     $mat_id = $m_id['match_id'];
     $match_id = (int) $mat_id;
     $sql = "SELECT club_id FROM club WHERE name={$club}";
     $c_id = $db->query($sql)->fetch(PDO::FETCH_ASSOC);
     $clu_id = $c_id['club_id'];
     $club_id = (int) $clu_id;
     $sql = "SELECT player.name,player_score,srate,balls FROM playerplay RIGHT JOIN player WHERE \n\t\tplayer.player_id = playerplay.player_id WHERE club_id = {$club_id}";
     $res = $db->query($sql);
     return $res->fetchAll(PDO::FETCH_ASSOC);
 }
 public function run($request)
 {
     $gp = ShopConfig::current()->CustomerGroup();
     if (empty($gp)) {
         return false;
     }
     $allCombos = DB::query("SELECT \"ID\", \"MemberID\", \"GroupID\" FROM \"Group_Members\" WHERE \"Group_Members\".\"GroupID\" = " . $gp->ID . ";");
     //make an array of all combos
     $alreadyAdded = array();
     $alreadyAdded[-1] = -1;
     if ($allCombos) {
         foreach ($allCombos as $combo) {
             $alreadyAdded[$combo["MemberID"]] = $combo["MemberID"];
         }
     }
     $unlistedMembers = DataObject::get("Member", $where = "\"Member\".\"ID\" NOT IN (" . implode(",", $alreadyAdded) . ")", $sort = null, $join = "INNER JOIN \"Order\" ON \"Order\".\"MemberID\" = \"Member\".\"ID\"");
     //add combos
     if ($unlistedMembers) {
         $existingMembers = $gp->Members();
         foreach ($unlistedMembers as $member) {
             $existingMembers->add($member);
             echo ".";
         }
     } else {
         echo "no new members added";
     }
 }
示例#12
0
 public static function authentication()
 {
     //		print_r($_SERVER);
     //		exit();
     if (!isset($_SERVER['PHP_AUTH_USER'])) {
         header('WWW-Authenticate: Basic realm="My Realm"');
         header('HTTP/1.0 401 Unauthorized');
         echo 'Text to send if user hits Cancel button';
         exit;
     } else {
         $db = new DB();
         $username = mysql_real_escape_string($_SERVER['PHP_AUTH_USER']);
         $password = mysql_real_escape_string($_SERVER['PHP_AUTH_PW']);
         $domain = 'nebula.com';
         $hash = md5($username . ':' . $domain . ':' . $password);
         $sql = "SELECT id from n_nebulauser WHERE username='******' AND ha1='{$hash}'";
         $q = $db->query($sql);
         if (mysql_num_rows($q)) {
             $fetch = mysql_fetch_assoc($q);
             return $fetch['id'];
         } else {
             return null;
         }
     }
     return false;
 }
function build_cache_fields_connect_register()
{
    global $_G;
    $data = array();
    $fields = array();
    if ($_G['setting']['connect']['register_gender']) {
        $fields[] = 'gender';
    }
    if ($_G['setting']['connect']['register_birthday']) {
        $fields[] = 'birthyear';
        $fields[] = 'birthmonth';
        $fields[] = 'birthday';
    }
    if ($fields) {
        $query = DB::query("SELECT * FROM " . DB::table('common_member_profile_setting') . " WHERE fieldid IN (" . dimplode($fields) . ")");
        while ($field = DB::fetch($query)) {
            $choices = array();
            if ($field['selective']) {
                foreach (explode("\n", $field['choices']) as $item) {
                    list($index, $choice) = explode('=', $item);
                    $choices[trim($index)] = trim($choice);
                }
                $field['choices'] = $choices;
            } else {
                unset($field['choices']);
            }
            $field['showinregister'] = 1;
            $field['available'] = 1;
            $data['field_' . $field['fieldid']] = $field;
        }
    }
    save_syscache('fields_connect_register', $data);
}
function updategroupcreditlog($fid, $uid)
{
    global $_G;
    if (empty($fid) || empty($uid)) {
        return false;
    }
    $today = date('Ymd', TIMESTAMP);
    $updategroupcredit = getcookie('groupcredit_' . $fid);
    if ($updategroupcredit < $today) {
        $status = DB::result_first("SELECT logdate FROM " . DB::table('forum_groupcreditslog') . " WHERE fid='{$fid}' AND uid='{$uid}' AND logdate='{$today}'");
        if (empty($status)) {
            DB::query("UPDATE " . DB::table('forum_forum') . " SET commoncredits=commoncredits+1 WHERE fid='{$fid}'");
            DB::query("REPLACE INTO " . DB::table('forum_groupcreditslog') . " (fid, uid, logdate) VALUES ('{$fid}', '{$uid}', '{$today}')");
            if (empty($_G['forum']) || empty($_G['forum']['level'])) {
                $forum = DB::fetch_first("SELECT name, level, commoncredits FROM " . DB::table('forum_forum') . " WHERE fid='{$fid}'");
            } else {
                $_G['forum']['commoncredits']++;
                $forum =& $_G['forum'];
            }
            if (empty($_G['grouplevels'])) {
                loadcache('grouplevels');
            }
            $grouplevel = $_G['grouplevels'][$forum['level']];
            if ($grouplevel['type'] == 'default' && !($forum['commoncredits'] >= $grouplevel['creditshigher'] && $forum['commoncredits'] < $grouplevel['creditslower'])) {
                $levelid = DB::result_first("SELECT levelid FROM " . DB::table('forum_grouplevel') . " WHERE type='default' AND creditshigher<='{$forum['commoncredits']}' AND creditslower>'{$forum['commoncredits']}' LIMIT 1");
                if (!empty($levelid)) {
                    DB::query("UPDATE " . DB::table('forum_forum') . " SET level='{$levelid}' WHERE fid='{$fid}'");
                    $groupfounderuid = DB::result_first("SELECT founderuid FROM " . DB::table('forum_forumfield') . " WHERE fid='{$fid}' LIMIT 1");
                    notification_add($groupfounderuid, 'system', 'grouplevel_update', array('groupname' => '<a href="forum.php?mod=group&fid=' . $fid . '">' . $forum['name'] . '</a>', 'newlevel' => $_G['grouplevels'][$levelid]['leveltitle']));
                }
            }
        }
        dsetcookie('groupcredit_' . $fid, $today, 86400);
    }
}
 public function delete($id, $admin = '')
 {
     if (empty($id)) {
         return false;
     }
     return DB::query('DELETE FROM %t WHERE ' . DB::field('id', $id) . ' %i', array($this->_table, $admin ? ' AND ' . DB::field('admin', $admin) : ''));
 }
 public function create($id)
 {
     //TODO clean output
     $this->workout_id = $id;
     $sql = sprintf("INSERT INTO exercises (workout_id,name,rep_min,rep_max,weight_min,weight_max,number_of_sets) VALUES ('%s','%s','%s','%s','%s','%s','%s')", $this->workout_id, $this->name, $this->setcount, $this->repmin, $this->repmax, $this->weightmin, $this->weightmax);
     return DB::query($sql);
 }
示例#17
0
 public function getLessonByNumber($lesson_number, $course_id)
 {
     $db = new DB();
     $query = "SELECT * FROM lessons WHERE lesson_number='" . $lesson_number . "' AND course_id='" . $course_id . "'";
     $date = $db->query($query);
     return $date[0];
 }
示例#18
0
 function usesubmit()
 {
     global $_G;
     if (empty($_G['gp_tid'])) {
         showmessage(lang('magic/sofa', 'sofa_info_nonexistence'));
     }
     $thread = getpostinfo($_G['gp_tid'], 'tid', array('fid', 'authorid', 'dateline', 'subject'));
     $this->_check($thread);
     $firstsofa = DB::result_first("SELECT COUNT(*) FROM " . DB::table('forum_threadmod') . " WHERE magicid='" . $this->magic['magicid'] . "' AND tid='{$_G['gp_tid']}'");
     if ($firstsofa >= 1) {
         showmessage(lang('magic/sofa', 'sofa_info_sofaexistence'), '', array(), array('login' => 1));
     }
     $sofamessage = lang('magic/sofa', 'sofa_text', array('actor' => $_G['member']['username'], 'time' => dgmdate(TIMESTAMP), 'magicname' => $this->magic['name']));
     $dateline = $thread['dateline'] + 1;
     insertpost(array('fid' => $thread['fid'], 'tid' => $_G['gp_tid'], 'first' => '0', 'author' => $_G['username'], 'authorid' => $_G['uid'], 'dateline' => $dateline, 'message' => $sofamessage, 'useip' => $_G['clientip'], 'usesig' => '1'));
     DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies+1, moderated='1' WHERE tid='{$_G['tid']}'", 'UNBUFFERED');
     DB::query("UPDATE " . DB::table('forum_forum') . " SET posts=posts+1, todayposts=todayposts+1 WHERE fid='{$post['fid']}'", 'UNBUFFERED');
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['gp_tid']);
     updatemagicthreadlog($_G['gp_tid'], $this->magic['magicid']);
     if ($thread['authorid'] != $_G['uid']) {
         notification_add($thread['authorid'], 'magic', lang('magic/sofa', 'sofa_notification'), array('tid' => $_G['gp_tid'], 'subject' => $thread['subject'], 'magicname' => $this->magic['name']));
     }
     showmessage(lang('magic/sofa', 'sofa_succeed'), dreferer(), array(), array('showdialog' => 1, 'locationtime' => 1));
 }
 /**
  * Returns true if the folder contains files
  * @return boolean
  */
 public function containsFiles()
 {
     if (!$this->owner instanceof Folder) {
         return false;
     }
     return (bool) DB::query("SELECT COUNT(*) FROM File WHERE ParentID = " . (int) $this->owner->ID . " AND ClassName NOT IN ('" . implode("','", array_values(ClassInfo::subclassesFor('Folder'))) . "')")->value();
 }
示例#20
0
 function getsetting()
 {
     global $_G;
     $settings = array('fids' => array('title' => 'couplebanner_fids', 'type' => 'mselect', 'value' => array()), 'groups' => array('title' => 'couplebanner_groups', 'type' => 'mselect', 'value' => array()), 'position' => array('title' => 'couplebanner_position', 'type' => 'mradio', 'value' => array(array(1, 'couplebanner_position_left'), array(2, 'couplebanner_position_right')), 'default' => 1), 'coupleadid' => array('title' => 'couplebanner_coupleadid', 'type' => 'select', 'value' => array()));
     loadcache(array('forums', 'grouptype'));
     $settings['fids']['value'][] = $settings['groups']['value'][] = array(0, '&nbsp;');
     $settings['fids']['value'][] = $settings['groups']['value'][] = array(-1, 'couplebanner_index');
     if (empty($_G['cache']['forums'])) {
         $_G['cache']['forums'] = array();
     }
     foreach ($_G['cache']['forums'] as $fid => $forum) {
         $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')) . $forum['name']);
     }
     foreach ($_G['cache']['grouptype']['first'] as $gid => $group) {
         $settings['groups']['value'][] = array($gid, str_repeat('&nbsp;', 4) . $group['name']);
         if ($group['secondlist']) {
             foreach ($group['secondlist'] as $sgid) {
                 $settings['groups']['value'][] = array($sgid, str_repeat('&nbsp;', 8) . $_G['cache']['grouptype']['second'][$sgid]['name']);
             }
         }
     }
     $query = DB::query('SELECT * FROM ' . DB::table('common_advertisement') . " WHERE type='couplebanner'");
     while ($couple = DB::fetch($query)) {
         $settings['coupleadid']['value'][] = array($couple['advid'], $couple['title']);
     }
     return $settings;
 }
    function doUp()
    {
        global $database;
        if (DBSchema::existsColumn($database, 'PresentationSpeaker', 'OnSitePhoneNumber')) {
            $speakers_info_query = <<<SQL
SELECT ID, OnSitePhoneNumber, ConfirmedDate, RegisteredForSummit
FROM PresentationSpeaker where OnSitePhoneNumber IS NOT NULL;
SQL;
            $res = DB::query($speakers_info_query);
            foreach ($res as $row) {
                $speaker_id = intval($row['ID']);
                $on_site_phone = intval($row['OnSitePhoneNumber']);
                $confirmed_date = $row['ConfirmedDate'];
                $registered = (bool) $row['RegisteredForSummit'];
                $speaker = PresentationSpeaker::get()->byID($speaker_id);
                if (is_null($speaker)) {
                    continue;
                }
                if (PresentationSpeakerSummitAssistanceConfirmationRequest::get()->filter(array('SummitID' => 5, 'SpeakerID' => $speaker_id))->count() > 0) {
                    continue;
                }
                $assistance = PresentationSpeakerSummitAssistanceConfirmationRequest::create();
                $assistance->SpeakerID = $speaker_id;
                $assistance->SummitID = 5;
                $assistance->OnSitePhoneNumber = $on_site_phone;
                $assistance->ConfirmationDate = $confirmed_date;
                $assistance->RegisteredForSummit = $registered;
                $assistance->IsConfirmed = true;
                $assistance->write();
            }
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'OnSitePhoneNumber');
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'ConfirmedDate');
            DBSchema::dropColumn($database, 'PresentationSpeaker', 'RegisteredForSummit');
        }
    }
示例#22
0
 function testMySQLCreateTableOptions()
 {
     if (DB::getConn() instanceof MySQLDatabase) {
         $ret = DB::query(sprintf('SHOW TABLE STATUS WHERE "Name" = \'%s\'', 'DatabaseTest_MyObject'))->first();
         $this->assertEquals($ret['Engine'], 'InnoDB', "MySQLDatabase tables can be changed to InnoDB through DataObject::\$create_table_options");
     }
 }
示例#23
0
 public function delete_by_touid($touids)
 {
     if (empty($touids)) {
         return false;
     }
     return DB::query('DELETE FROM mc, mq USING %t AS mc, %t AS mq WHERE mc.' . DB::field('touid', $touids) . ' AND mc.cid=mq.cid', array($this->_table, 'common_mailqueue'), false, true);
 }
示例#24
0
 public function GroupedCalendarEventsByDate()
 {
     $view = $this->getRequest()->getVar('view');
     if ($view == "thisweek") {
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` WHERE `Date` >= DATE_ADD(CURDATE(), INTERVAL (0 - WEEKDAY(CURDATE())) DAY) AND `Date` < DATE_ADD(CURDATE(), INTERVAL (7 - WEEKDAY(CURDATE())) DAY) ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     } elseif ($view == "nextweek") {
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` WHERE `Date` >= DATE_ADD(CURDATE(), INTERVAL (0 - WEEKDAY(CURDATE()) + 7) DAY) AND `Date` < DATE_ADD(CURDATE(), INTERVAL (7 - WEEKDAY(CURDATE()) + 7) DAY) ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     } elseif ($view == "thismonth") {
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` WHERE `Date` >= CONCAT(DATE_FORMAT(LAST_DAY(CURDATE()),'%Y-%m-'), '01') AND `Date` <= LAST_DAY(CURDATE()) ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     } elseif ($view == "nextmonth") {
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` WHERE `Date` >= CONCAT(DATE_FORMAT(LAST_DAY(DATE_ADD(CURDATE(), INTERVAL 1 MONTH)), '%Y-%m-'), '01') AND `Date` <= LAST_DAY(DATE_ADD(CURDATE(), INTERVAL 1 MONTH)) ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     } elseif ($view == "thisyear") {
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` WHERE `Date` >= CONCAT(YEAR(CURDATE()), '-01-01') AND `Date` <= CONCAT(YEAR(CURDATE()), '-12-31') ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     } elseif ($view == "nextyear") {
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` WHERE `Date` >= CONCAT(YEAR(CURDATE()) + 1, '-01-01') AND `Date` <= CONCAT(YEAR(CURDATE()) + 1, '-12-31') ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     } elseif ($view == "all") {
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` WHERE `Date` >= CURDATE() ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     } elseif ($view == "events") {
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     } else {
         // Default to the next 14 days
         $sql = "SELECT `CalendarEvent`.*, `CalendarEventDate`.`Date`, DATE_FORMAT(`CalendarEventDate`.`Date`, '%W %e %M %Y') AS `FormattedDate` FROM `CalendarEvent` INNER JOIN `CalendarEventDate` ON `CalendarEventDate`.`CalendarEventID` = `CalendarEvent`.`ID` WHERE `Date` >= CURDATE() AND `Date` <= DATE_ADD(CURDATE(), INTERVAL 14 DAY) ORDER BY `CalendarEventDate`.`Date`, `CalendarEvent`.`StartTime`, `CalendarEvent`.`EndTime`";
     }
     $records = DB::query($sql);
     foreach ($records as $record) {
         $objects[] = new $record['ClassName']($record);
     }
     if (isset($objects)) {
         $arrayList = new ArrayList($objects);
     } else {
         $arrayList = new ArrayList();
     }
     return GroupedList::create($arrayList);
 }
示例#25
0
文件: class.php 项目: hqd276/bigs
 function ManageSupport($row)
 {
     Module::Module($row);
     if (User::is_admin() || User::have_permit(support_all_perm)) {
         CGlobal::$website_title = 'Quản lý thư góp ý của khách hàng';
         switch (Url::get('cmd')) {
             case 'delete':
                 DB::query('DELETE FROM support WHERE id=' . EClassApi::getParam('id'));
                 Url::redirect_url(Url::build_all(array('chk_id', 'del_all', 'cmd', 'id')));
                 break;
             case "edit":
                 /*case "add":
                 		require_once 'forms/edit.php';		
                 		$this->add_form(new EditBadWordForm());
                 		break;*/
             /*case "add":
             		require_once 'forms/edit.php';		
             		$this->add_form(new EditBadWordForm());
             		break;*/
             default:
                 require_once 'forms/list.php';
                 $this->add_form(new ManageSupportForm());
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
function build_cache_forumrecommend()
{
    $data = array();
    $query = DB::query("SELECT fid FROM " . DB::table('forum_forum') . " WHERE type<>'group' AND status<>3");
    while ($row = DB::fetch($query)) {
        require_once libfile('function/group');
        $squery = DB::query("SELECT f.fid, f.name, f.threads, f.lastpost, ff.icon, ff.membernum, ff.description FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid WHERE recommend='{$row['fid']}'");
        while ($group = DB::fetch($squery)) {
            $group['icon'] = get_groupimg($group['icon'], 'icon');
            $lastpost = array(0, 0, '', '');
            $group['lastpost'] = is_string($group['lastpost']) ? explode("\t", $group['lastpost']) : $group['lastpost'];
            $group['lastpost'] = count($group['lastpost']) != 4 ? $lastpost : $group['lastpost'];
            list($lastpost['tid'], $lastpost['subject'], $lastpost['dateline'], $lastpost['author']) = $group['lastpost'];
            if ($lastpost['tid']) {
                $lastpost['dateline'] = dgmdate($lastpost['dateline'], 'Y-m-d H:i:s');
                if ($lastpost['author']) {
                    $lastpost['encode_author'] = rawurlencode($lastpost['author']);
                }
                $group['lastpost'] = $lastpost;
            } else {
                $group['lastpost'] = '';
            }
            $data[$row['fid']][] = $group;
        }
    }
    save_syscache('forumrecommend', $data);
}
 public function run($request)
 {
     // update block/set titles
     // Name field has been reverted back to Title
     // DB::query("update Block set Name = Title");
     // DB::query("update BlockSet set Name = Title");
     // update block areas
     DB::query("\n\t\t\tupdate SiteTree_Blocks\n\t\t\tleft join Block on SiteTree_Blocks.BlockID = Block.ID\n\t\t\tset BlockArea = Block.Area\n\t\t\twhere BlockID = Block.ID\n\t\t");
     // update block sort
     DB::query("\n\t\t\tupdate SiteTree_Blocks\n\t\t\tleft join Block on SiteTree_Blocks.BlockID = Block.ID\n\t\t\tset Sort = Block.Weight\n\t\t\twhere BlockID = Block.ID\n\t\t");
     echo "BlockAreas, Sort updated<br />";
     // migrate global blocks
     $sc = SiteConfig::current_site_config();
     if ($sc->Blocks()->Count()) {
         $set = BlockSet::get()->filter('Title', 'Global')->first();
         if (!$set) {
             $set = BlockSet::create(array('Title' => 'Global'));
             $set->write();
         }
         foreach ($sc->Blocks() as $block) {
             if (!$set->Blocks()->find('ID', $block->ID)) {
                 $set->Blocks()->add($block, array('Sort' => $block->Weight, 'BlockArea' => $block->Area));
                 echo "Block #{$block->ID} added to Global block set<br />";
             }
         }
     }
     // publish blocks
     $blocks = Block::get()->filter('Published', 1);
     foreach ($blocks as $block) {
         $block->publish('Stage', 'Live');
         echo "Published Block #{$block->ID}<br />";
     }
 }
示例#28
0
 public function delete_by_pid($pids)
 {
     if (empty($pids)) {
         return false;
     }
     return DB::query('DELETE FROM %t WHERE ' . DB::field('pid', $pids), array($this->_table), false, true);
 }
示例#29
0
文件: Sql.php 项目: jubinpatel/horde
 /**
  * Write out the tags for a specific resource.
  *
  * @param int    $resource_id    The story we are tagging.
  * @param int    $channel_id     The channel id for the story we are tagging
  * @param array  $tags           An array of tags.
  *
  * @TODO: Move this to a tagger class that uses Content_Tagger
  * @return boolean
  * @throws Jonah_Exception
  */
 public function writeTags($resource_id, $channel_id, $tags)
 {
     global $conf;
     // First, make sure all tag names exist in the DB.
     $tagkeys = array();
     $insert = $this->_db->prepare('INSERT INTO jonah_tags (tag_id, tag_name) VALUES(?, ?)');
     $query = $this->_db->prepare('SELECT tag_id FROM jonah_tags WHERE tag_name = ?');
     foreach ($tags as $tag) {
         $tag = Horde_String::lower(trim($tag));
         $results = $this->_db->execute($query, $this->_db->escapeSimple($tag));
         if ($results instanceof PEAR_Error) {
             throw new Jonah_Exception($results);
         } elseif ($results->numRows() == 0) {
             $id = $this->_db->nextId('jonah_tags');
             $result = $this->_db->execute($insert, array($id, $tag));
             $tagkeys[] = $id;
         } else {
             $row = $results->fetchRow(DB_FETCHMODE_ASSOC);
             $tagkeys[] = $row['tag_id'];
         }
     }
     // Free our resources.
     $this->_db->freePrepared($insert, true);
     $this->_db->freePrepared($query, true);
     $sql = 'DELETE FROM jonah_stories_tags WHERE story_id = ' . (int) $resource_id;
     $query = $this->_db->prepare('INSERT INTO jonah_stories_tags (story_id, channel_id, tag_id) VALUES(?, ?, ?)');
     Horde::log('SQL query by Jonah_Driver_sql::writeTags: ' . $sql, 'DEBUG');
     $this->_db->query($sql);
     foreach ($tagkeys as $key) {
         $this->_db->execute($query, array($resource_id, $channel_id, $key));
     }
     $this->_db->freePrepared($query, true);
     /* @TODO We should clear at least any of our cached counts */
     return true;
 }
 public function fetch_all_by_bid($bid, $isverified = 1, $start = 0, $limit = 0, $bannedids = array(), $format = true)
 {
     $data = array();
     if ($bid = dintval($bid, true)) {
         $addsql = $bannedids = dintval($bannedids, true) ? ' AND id NOT IN (' . dimplode($bannedids) . ')' : '';
         $query = DB::query('SELECT * FROM %t WHERE ' . DB::field('bid', $bid) . ' AND isverified=%d' . $addsql . ' ORDER BY stickgrade DESC, displayorder DESC, verifiedtime DESC, dataid DESC ' . DB::limit($start, $limit), array($this->_table, $isverified));
         while ($value = DB::fetch($query)) {
             if ($format) {
                 $value['fields'] = unserialize($value['fields']);
                 $value['fields']['timestamp'] = $value['fields']['dateline'];
                 $value['fields']['dateline'] = dgmdate($value['fields']['dateline']);
                 $value['pic'] = $value['pic'] !== STATICURL . 'image/common/nophoto.gif' ? $value['pic'] : '';
                 if ($value['pic'] && $value['picflag'] == '1') {
                     $value['pic'] = getglobal('setting/attachurl') . $value['pic'];
                 } elseif ($value['picflag'] == '2') {
                     $value['pic'] = getglobal('setting/ftp/attachurl') . $value['pic'];
                 }
                 $value['dateline'] = dgmdate($value['dateline'], 'u');
                 $value['verifiedtime'] = dgmdate($value['verifiedtime'], 'u');
             }
             $data[$value['id']] = $value;
         }
     }
     return $data;
 }