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


PHP sql::connect方法代码示例

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


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

示例1: content

 function content()
 {
     $db = new sql();
     $db->connect();
     if (time() < 1098388800) {
         $res = $db->query("select projects.id, name, company, category, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM projects left join votes on projects.id=votes.id group by projects.id, name, company, category order by gsum desc");
     } else {
         $res = $db->query("select projects.id, name, company, category, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM projects left join votes on projects.id=votes.id where grade>0 group by projects.id, name, company, category order by gsum desc");
     }
     $cats = array(1 => "A", "C", "Y");
     $tr = "";
     while ($data = $db->fetch_array($res)) {
         $res1 = $db->query("select * from categories where category_id={$data['category']}");
         $data1 = $db->fetch_array($res1);
         $url = "/projects/" . $cats[$data1["category_id"]] . "/";
         eval('$tr.="' . page::template("modules/resultTR") . '";');
     }
     if (!$tr) {
         $tr = "<p style=\"font-size: 0.85em;\">В настоящее время в данной номинации заявок не подано.</p><p style=\"font-size: 0.85em;\"><a href=\"/request/\">Заявки</a> принимаются до 15 октября 2004 года</p>";
     }
     $resultTr .= $tr;
     if ($resultTr) {
         eval('$projectsMain.="' . page::template("modules/resultMain") . '";');
     }
     $resultTr = "";
     if (time() < 1098388800) {
         $text = "<p>Здесь размещены текущие результаты голосования, обновляющиеся в режиме реального времени.</p><p>Для того, чтобы проголосовать за проект надо перейти на его страницу.</p><p>Вы можете поставить свою оценку каждому из 22 представленных проектов, но можете сделать это только 1 раз за весь период голосования.</p><p>Голосование открыто до 0:00 22 октября 2004 года.</p>";
     } else {
         $text = "<h3>Голование закрыто в&nbsp;0:00 22&nbsp;октября 2004&nbsp;года.</h3><p><i>При анализе хода голосования за&nbsp;проекты в&nbsp;интернете, Оргкомитет конкурса М2.&nbsp;Новый&nbsp;Дом&nbsp;2004. обнаружил многочисленные случаи злоупотребления при выставлении оценки 0&nbsp;баллов. В&nbsp;целях повышения релевантности итогов голосования, Оргкомитет принял решение не&nbsp;учитывать оценки 0&nbsp;баллов, выставленные за&nbsp;весь период голосования в&nbsp;интернете.</i></p>";
     }
     $this->elements["content"] = $text . $projectsMain;
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:32,代码来源:votelist.class.php

示例2: defaultAction

 function defaultAction()
 {
     $db = new sql();
     $db->connect();
     $chid = $this->chid;
     include "lib/pagination.class.php";
     include "lib/orderby.class.php";
     $adminConfig = admin::adminConfig();
     for ($i = 1; $i < 4; $i++) {
         $voteTR = "";
         $orderBy = new orderBy("?chid=" . $this->chid . "&", array("id" => "№", "time" => "Дата", "name" => "Заголовок", "company" => "Компания", "gsum" => "Средний бал", "gcount" => "Проголосовало"), array("gsum" => "desc"), $this->field[$i], $this->order[$i], array("field[{$i}]", "order[{$i}]"));
         $pagination = new pagination($orderBy->urlForPage(), $this->page, $adminConfig["recPerPage"], '', "projects", "id");
         $res = $db->query("select projects.id, name, company, category_name, date, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM (projects LEFT JOIN categories ON projects.category = categories.category_id) left join votes on projects.id=votes.id where category={$i} group by projects.id, name, company, category_name, date " . $orderBy->orderByQuery() . " " . $pagination->limit());
         $page = $this->page ? "&page=" . $this->page : "";
         while ($data = $db->fetch_array($res)) {
             $data["date"] = date("d.m.Y", $data["date"]);
             eval('$voteTR.="' . admin::template("voteTR") . '";');
         }
         $pageBar = $pagination->bar();
         $th = $orderBy->bar();
         eval('$content.="' . admin::template("voteMain") . '";');
         $content .= "<br>";
     }
     $this->elements["content"] = $content;
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:25,代码来源:vote.class.php

示例3: defaultAction

 function defaultAction()
 {
     global $HTTP_SERVER_VARS;
     include "./lib/config.inc.php";
     $db = new sql();
     $db->connect();
     $result = $db->query('SELECT VERSION() AS version');
     if ($result != FALSE && $db->num_rows($result) > 0) {
         $row = $db->fetch_array($result);
         $match = $row['version'];
     } else {
         $result = $db->query('SHOW VARIABLES LIKE \'version\'');
         if ($result != FALSE && $db->num_rows($result) > 0) {
             $row = $db->fetch_array($result);
             $match = $row[1];
         }
     }
     $this->MYSQL_VER = $match;
     $this->PHP_OS = PHP_OS;
     $this->PHP_VERSION = PHP_VERSION;
     $this->CMS = $admin_config["name"] . " " . $admin_config["version"];
     $this->AUTHOR = $admin_config["author"];
     $this->HOME_PAGE = $admin_config["home_page"];
     $content = admin::template("info", $this);
     $this->elements["content"] = $content;
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:26,代码来源:content.class.php

示例4: rightBar

 function rightBar()
 {
     $db = new sql();
     $db->connect();
     $res = $db->query(" select * from news order by time desc limit 0, 3");
     while ($data = $db->fetch_array($res)) {
         $this->elements["rightBar"] .= '<table><tr><th>' . $data["title"] . ':</th></tr><tr><td>' . $data["text"] . '</td></tr></table>';
     }
     $this->elements["rightBar"] = '<td valign="top" style="padding-left: 1em;">' . $this->elements["rightBar"] . '<p align="right"><a href="/news/">¬се новости &rarr;</a></p><br><i>¬ принципе, вы можете зайти и ознакомитьс¤ с <a href="/timeline/" target="_self">хронологией моих работ</a> (благо, их пока не так уж много).</i><p align="right"><a href="/card/" target="_self"> арта сайта &rarr;</a></p></td>';
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:10,代码来源:index.class.php

示例5: appendEdit

 function appendEdit()
 {
     $this->fields["time"] = mktime(0, 0, 0, $this->date["month"], $this->date["day"], $this->date["year"]);
     foreach ($this->fields as $key => $value) {
         $query .= "{$key}='{$value}', ";
     }
     $query = substr($query, 0, strlen($s) - 2);
     $db = new sql();
     $db->connect();
     $db->query("update news set {$query} where id=" . $this->fields["id"]);
     header("Location: ?chid=" . $this->chid . "&m=3");
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:12,代码来源:news.class.php

示例6: got_child

function got_child($id)
{
    $db = new sql();
    $db->connect();
    $res = $db->query(_QUERY . " where pid={$id}");
    if ($db->num_rows($res) > 0) {
        return true;
        exit;
    } else {
        return false;
        exit;
    }
}
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:13,代码来源:links.php

示例7: pagination

 function pagination($curUrl, $curPage, $recPerPage, $totalCount, $tableName = "", $fieldName = "", $where = "")
 {
     $this->url = $curUrl;
     $this->page = $curPage ? $curPage : 1;
     $this->recPerPage = $recPerPage;
     if ($totalCount) {
         $this->totalRecCount = $totlaCount;
     } else {
         $db = new sql();
         $db->connect();
         $db->query("select count({$fieldName}) as rec_count from {$tableName} {$where}");
         $data = $db->fetch_array($db->result);
         $this->totalRecCount = $data["rec_count"];
     }
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:15,代码来源:pagination.class.php

示例8: admin

 function admin()
 {
     include_once "./lib/config.inc.php";
     session_start();
     if ($_GET["action"] == "logout") {
         session_destroy();
         header("Location: ./");
     }
     if (!$_SESSION["user_id"]) {
         if ($_POST["user"] && $_POST["pass"]) {
             $db = new sql();
             $db->connect();
             $res = $db->query("select id, pass from users where login='" . $_POST["user"] . "'");
             $data = $db->fetch_array($res);
             if ($data["pass"] == md5($_POST["pass"])) {
                 $_SESSION["user_id"] = $data["id"];
                 header("Location: ./");
             } else {
                 $this->message = "<h3 style=\"color: red;\">Ќеправильный логин или пароль!!!</h3>";
                 $login = $page->template("login", $this);
                 echo $login;
                 exit;
             }
         } else {
             $login = $this->template("login", $this);
             echo $login;
             exit;
         }
     } else {
         $db = new sql();
         $db->connect();
         $res = $db->query("select id, name, admin from users where id=" . $_SESSION["user_id"]);
         $data = $db->fetch_array($res);
         $this->user = $data["name"];
         $this->user_id = $data["id"];
         $this->user_admin = $data["admin"];
     }
     $this->nav = $nav;
     $this->admin_config = $admin_config;
     $this->id = $_GET["chid"] ? $_GET["chid"] : 1;
     $this->action = $_GET["action"];
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:42,代码来源:adm.class.php

示例9: sql

 function _sel($id = 0, $url = "", $menu = 0)
 {
     $db = new sql();
     $db->connect();
     if ($menu == 1) {
         $where = " and menu=1";
     } else {
         $where = " and menu!=1";
     }
     $res = $db->query("select id, title, url from chapters where (pid={$id} and url<>'searchresult' and url<>'sitemap' and type<>4 and id<>1){$where} order by sortorder");
     if ($db->num_rows($res) > 0) {
         $sel = "<ul>";
         while ($data = $db->fetch_array($res)) {
             $str .= $data["title"];
             $url1 = $url . "/" . $data["url"];
             $sel .= "<li type=\"disc\"><a href=\"{$url1}/\">" . $data["title"] . "</a>\n";
             $sel .= $this->_sel($data["id"], $url1);
             $sel .= "</li>\n";
         }
         $sel .= "</ul>";
         return $sel;
     }
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:23,代码来源:sitemap.class.php

示例10: connect

<?php

class sql
{
    var $mysql;
    function connect($host, $name, $pass, $bd)
    {
        $this->mysql = 'mysql_connect(localhost,valeriy42,ogenum21)';
        $this->mysql = 'mysql_select_db(valeriy42_skazochnik)';
        $this->mysql = 'mysql_query (set character_set_client="utf8")';
        $this->mysql = 'mysql_query (set character_set_results="utf8")';
        $this->mysql = 'mysql_query (set collation_connection="utf8_general_ci")';
    }
}
$r = new sql();
$r->connect(localhost, valeriy42, ogenum21, valeriy42_skazochnik);
var_dump($r);
开发者ID:k9lis,项目名称:cms,代码行数:17,代码来源:function.php

示例11: showAuthorSelectJS

 function showAuthorSelectJS()
 {
     $db = new sql();
     $db->connect();
     $res = $db->query("select id, firstname, secondname, lastname from authors order by lastname, firstname, secondname");
     while ($data = $db->fetch_array($res)) {
         $i++;
         $chid = $this->chid;
         $data["fio"] = $data["lastname"] . ($data["firstname"] ? " " . $data["firstname"] : "") . ($data["secondname"] ? " " . $data["secondname"] : "");
         eval('$authorsJSline.="' . admin::template("authorsJSline") . '";');
     }
     eval('$content="' . admin::template("authorsJS") . '";');
     echo $content;
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:14,代码来源:authors.class.php

示例12: template

$field = $form->addRawField('<h4>' . lang::get('user') . '</h4>');
$field = $form->addTextField('firstname', '');
$field->addValidator('notEmpty', lang::get('validator_not_empty'));
$field->fieldName(lang::get('firstname'));
$field = $form->addTextField('name', '');
$field->addValidator('notEmpty', lang::get('validator_not_empty'));
$field->fieldName(lang::get('name'));
$field = $form->addTextField('email', '');
$field->fieldName(lang::get('email'));
$field->addValidator('notEmpty', lang::get('validator_not_empty'));
$field->addValidator('email', lang::get('user_wrong_email'));
$field = $form->addTextField('password', '');
$field->addValidator('notEmpty', lang::get('validator_not_empty'));
$field->fieldName(lang::get('password'));
if ($form->isSubmit()) {
    $sql = sql::connect($form->get('db_host'), $form->get('db_user'), $form->get('db_password'), $form->get('db_database'));
    if (is_null($sql)) {
        $DB = ['host' => $form->get('db_host'), 'user' => $form->get('db_user'), 'password' => $form->get('db_password'), 'database' => $form->get('db_database'), 'prefix' => $form->get('db_prefix')];
        dyn::add('DB', $DB, true);
        dyn::add('setup', false, true);
        dyn::save();
        install::newInstall();
        install::insertDemoContent();
        $template = new template(dyn::get('template'));
        if ($template->install() !== true) {
            $form->setSuccessMessage(null);
            $error = true;
        }
        $form->addParam('page', 'finish');
    } else {
        echo message::danger($sql);
开发者ID:pasternt,项目名称:dynaoCMS,代码行数:31,代码来源:database.php

示例13: appendEdit

 function appendEdit()
 {
     if ($this->fields["pass"]) {
         $this->fields["pass"] = md5($this->fields["pass"]);
     } else {
         unset($this->fields["pass"]);
     }
     foreach ($this->fields as $key => $value) {
         $query .= "{$key}='{$value}', ";
     }
     $query = substr($query, 0, strlen($s) - 2);
     $db = new sql();
     $db->connect();
     $db->query("update users set {$query} where id=" . $this->fields["id"]);
     header("Location: ?chid=" . $this->chid . "&m=3");
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:16,代码来源:users.class.php

示例14: getConfig

 function getConfig()
 {
     $db = new sql();
     $db->connect();
     $res = $db->query("select * from config");
     while ($data = $db->fetch_array($res)) {
         $this->config[$data["name"]] = $data["text"];
     }
     return $this->config;
 }
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:10,代码来源:page.class.php

示例15: conf

function conf()
{
    $db = new sql();
    $db->connect();
    $db->query("select * from subs_config");
    $d = $db->fetch_array($db->result);
    $d["text"] = addslashes(str_replace("\r", "", $d["text"]));
    $d["html"] = addslashes(str_replace("\r", "", $d["html"]));
    return $d;
}
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:10,代码来源:subcribe.class.php


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