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


PHP close_db函数代码示例

本文整理汇总了PHP中close_db函数的典型用法代码示例。如果您正苦于以下问题:PHP close_db函数的具体用法?PHP close_db怎么用?PHP close_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: check_answer_exist

function check_answer_exist($user_id, $survey_id, $question_id, $option_id)
{
    $connection = connect_db();
    $sql = "SELECT *\n   \t\t\tFROM user_answers\n   \t\t\tWHERE user_id=" . $user_id . " AND survey_id=" . $survey_id . " AND question_id=" . $question_id . " AND option_id=" . $option_id;
    $query_results = mysqli_query($connection, $sql) or die(mysql_error());
    $answer_exists = mysqli_num_rows($query_results) > 0 ? true : false;
    return $answer_exists;
    close_db($connection);
}
开发者ID:joelafrica,项目名称:planitsurvey,代码行数:9,代码来源:db_lib.php

示例2: getDirectors

 function getDirectors()
 {
     connect_db();
     $directors = array();
     foreach ($this->director_order as $uid) {
         $directors[] = get_object('Director', $uid);
     }
     close_db();
     return $directors;
 }
开发者ID:rchrd2,项目名称:db_serialize,代码行数:10,代码来源:model_classes.php

示例3: updatePlugins

 function updatePlugins()
 {
     connect_db();
     $list = $this->getPluginsList();
     // Delete anything lingering in the database
     mysql_query("TRUNCATE TABLE plugins");
     foreach (array_slice($list, 0, 999) as $fileNames) {
         $this->parseFilename($fileNames);
     }
     close_db();
     echo 'Success!';
 }
开发者ID:tkrugg,项目名称:QSApp.com,代码行数:12,代码来源:update.php

示例4: updateData

 /**
  * Update one item in the table
  * @param VOTimeline to be updated 
  * @return NULL
  */
 public function updateData($obj)
 {
     if ($obj == NULL) {
         return NULL;
     }
     //connect to the database.
     $DB = connect_db(false);
     //save changes
     $sql = "UPDATE btk_user_info SET ts_username='" . $obj->tsUsername . "', ts_password='" . $obj->tsPassword . "',reg_username='" . $obj->regUsername . "', reg_password='" . $obj->regPassword . "'";
     $DB->execute($sql);
     close_db($DB);
     return NULL;
 }
开发者ID:bogus,项目名称:findik-web-amf,代码行数:18,代码来源:BTKUserInfoService.php

示例5: deleteData

 public function deleteData($obj)
 {
     if ($obj == NULL) {
         return NULL;
     }
     //connect to the database.
     $DB = connect_db(false);
     //save changes
     $sql = "DELETE FROM mime_type_cross WHERE id=?";
     $DB->execute($sql, array($obj->id));
     close_db($DB);
     return NULL;
 }
开发者ID:bogus,项目名称:findik-web-amf,代码行数:13,代码来源:MimeCrossService.php

示例6: genpassword

function genpassword()
{
    echo "new password list...<br>\n";
    connect_db();
    //  $res = mysql_query("SELECT * FROM user_info WHERE NOT(type='A')");
    $res = mysql_query("SELECT * FROM user_info WHERE (type='C')");
    $row = mysql_num_rows($res);
    for ($i = 0; $i < $row; $i++) {
        echo mysql_result($res, $i, 'user_id') . ':';
        echo mysql_result($res, $i, 'name') . ':';
        $pass = randpass();
        echo $pass . "<br>\n";
        setpassword(mysql_result($res, $i, 'user_id'), $pass);
    }
    close_db();
}
开发者ID:elsayhsoft,项目名称:fossil-grader,代码行数:16,代码来源:random_user_password.php

示例7: listuser

function listuser()
{
    echo '<table border=1>';
    echo '<tr><td width="10%"><b>username</b></td>';
    echo '<td width="40%"><b>name</b></td><td><b>password</b></td></tr>';
    connect_db();
    $res = mysql_query("SELECT * FROM user_info WHERE NOT(type='A')");
    $row = mysql_num_rows($res);
    for ($i = 0; $i < $row; $i++) {
        echo '<tr><td>' . mysql_result($res, $i, 'user_id') . '</td>';
        echo '<td>' . mysql_result($res, $i, 'name') . '</td>';
        echo '<td>' . mysql_result($res, $i, 'passwd') . "</td></tr>\n";
    }
    close_db();
    echo '</table>';
}
开发者ID:elsayhsoft,项目名称:fossil-grader,代码行数:16,代码来源:list_password.php

示例8: toFile

/**
 * @author Tuan Anh
 * @copyright 2011
 */
function toFile($result, $id, $bd, $fn)
{
    require_once '../src/db.php';
    $con = connect_db();
    $fh = fopen($fn, 'a') or die('cant open file');
    //check if $result empty
    if ($result == '') {
        return;
    }
    //insert name and student_id to student table
    $str = '';
    $str .= " /*" . $stt . "====================================' .{$id}.'-'.{$result['0']}.'===============================*/" . "\n";
    $str .= 'INSERT INTO student VALUES ("' . $id . '", "' . $result[0] . '","' . $bd . '");' . "\n";
    //insert each term
    for ($i = 1; $i < count($result); $i++) {
        $str .= '/*======================' . $result[$i]['hk'] . '======================*/' . "\n";
        $j = 0;
        $count = count($result[$i]) - 7;
        while ($j < $count) {
            //check if subject_id exits
            $subject_id = $result[$i][$j];
            $subject_name = $result[$i][$j + 1];
            $subject_credit = $result[$i][$j + 3];
            if (!check_exits($subject_id, 'subject', 'subject_id')) {
                //insert subject_id, subject_name, credit
                $str .= 'INSERT INTO subject VALUES ("' . $subject_id . '","' . $subject_name . '",' . $subject_credit . ');' . "\n";
            }
            //insert mid_term, end_term, avg
            $group = $result[$i][$j + 2];
            $mid_grade = $result[$i][$j + 4] == '---' ? 'NULL' : $result[$i][$j + 4];
            $end_grade = $result[$i][$j + 5] == '---' ? 'NULL' : $result[$i][$j + 5];
            $avg_grade = $result[$i][$j + 6] == '---' ? 'NULL' : $result[$i][$j + 6];
            $str .= 'INSERT INTO score_term VALUES ("' . $id . '", "' . $result[$i]['hk'] . '","' . $result[$i][$j] . '",' . $mid_grade . ',' . $end_grade . ',' . $avg_grade . ',"' . $group . '");' . "\n";
            $j += 7;
        }
        //insert into term_stat
        $sum_credit_reg_term = $result[$i]['sum_credit_reg_term'] == '' ? 'NULL' : $result[$i]['sum_credit_reg_term'];
        $sum_credit_all_term = $result[$i]['sum_credit_all_term'] == '' ? 'NULL' : $result[$i]['sum_credit_all_term'];
        $avg_term = $result[$i]['avg_term'] == '' ? 'NULL' : $result[$i]['avg_term'];
        $sum_credit = $result[$i]['sum_credit'] == '' ? 'NULL' : $result[$i]['sum_credit'];
        $avg_all = $result[$i]['avg_all'] == '' ? 'NULL' : $result[$i]['avg_all'];
        $str .= 'INSERT INTO term_stat VALUES ("' . $result[$i]['hk'] . '" ,"' . $id . '" ,' . $sum_credit_reg_term . ' ,' . $sum_credit_all_term . ' ,' . $avg_term . ' ,' . $sum_credit . ' ,' . $avg_all . ');' . "\n";
    }
    fwrite($fh, $str . "\n");
    fclose($fh);
    close_db($con);
}
开发者ID:Zham10,项目名称:ecbk,代码行数:51,代码来源:toFile.php

示例9: books_get

 public function books_get()
 {
     $book_id = isset($this->_params[0]) ? $this->_params['0'] : '';
     if (!is_numeric($this->_params[0])) {
         throw new Exception("invalid parameters in request", 400);
     }
     require_once 'include/connect_db.php';
     $conn = connect_db();
     $book_id = $conn->real_escape_string($book_id);
     $sql_query = "SELECT COUNT(*) FROM `books` WHERE";
     $sql_query .= "`id`='{$book_id}'";
     if ($result = $conn->query($sql_query)) {
         $row = mysqli_fetch_row($result);
         $count = $row[0];
     } else {
         close_db($conn);
         throw new Exception("db error", 500);
     }
     if ($count == 0) {
         close_db($conn);
         throw new Exception("no book found", 404);
     } else {
         $sql_query = "SELECT b.*, p.`name` as publisher, s.`name` as subject FROM `books`b, `publishers`p, `subjects`s WHERE ";
         $sql_query .= "b.`id`='{$book_id}' AND p.`id`=b.`publisher_id` AND s.`id`=b.`subject_id` LIMIT 1";
         if ($result = $conn->query($sql_query)) {
             $row = mysqli_fetch_assoc($result);
             unset($row['publisher_id']);
             if ($row['img'] === '1') {
                 $row['img_url'] = "http://www.campusbookie.net/img/book/" . $row['isbn'] . ".jpg";
             } else {
                 $row['img_url'] = "http://www.campusbookie.net/img/book/" . "no-image.jpg";
             }
             $row['_links']['self']['href'] = "/books/" . $book_id;
             $retData = array();
             $retData['staus'] = "success";
             $retData['message'] = null;
             $retData['data'] = $row;
             close_db($conn);
             return array('data' => $retData, 'status' => 200);
         } else {
             close_db($conn);
             throw new Exception("db error", 500);
         }
     }
 }
开发者ID:anush-cr,项目名称:campusbookie,代码行数:45,代码来源:books.php

示例10: getData

 /**
  * Retrieve all the records from the table
  * @return an array of VOUser
  */
 public function getData($searchKey = null)
 {
     //connect to the database.
     $DB = connect_db(false);
     //retrieve all rows
     $rs = $DB->Execute("SELECT * FROM users ORDER BY username");
     $ret = array();
     while (!$rs->EOF) {
         $tmp = new VOUser();
         $tmp->id = $rs->fields["id"];
         $tmp->username = $rs->fields["username"];
         $tmp->password = $rs->fields["password"];
         $ret[] = $tmp;
         $rs->MoveNext();
     }
     return $ret;
     close_db($DB);
 }
开发者ID:bogus,项目名称:findik-web-amf,代码行数:22,代码来源:UserService.php

示例11: getData

 /**
  * Retrieve all the records from the table
  * @return an array of VOTimeline
  */
 public function getData($searchKey = null)
 {
     //connect to the database.
     $DB = connect_db(false);
     //retrieve all rows
     $rs = $DB->Execute("SELECT * FROM btk_db_update ORDER BY update_date DESC LIMIT 1");
     $ret = array();
     while (!$rs->EOF) {
         $tmp = new VOBTKGeneralInfo();
         $tmp->updateName = $rs->fields["update_id"];
         $tmp->updateDate = $rs->fields["update_date"];
         $tmp->currentClient = 10;
         $ret[] = $tmp;
         $rs->MoveNext();
     }
     return $ret;
     close_db($DB);
 }
开发者ID:bogus,项目名称:findik-web-amf,代码行数:22,代码来源:BTKGeneralInfoService.php

示例12: getData

 /**
  * Retrieve all the records from the table
  * @return an array of VOTimeline
  */
 public function getData($searchKey = null)
 {
     //connect to the database.
     $DB = connect_db(false);
     //retrieve all rows
     $rs = $DB->Execute("SELECT * FROM btk_timestamp_history ORDER BY id");
     $ret = array();
     while (!$rs->EOF) {
         $tmp = new VOBTKTimestampHistory();
         $tmp->id = $rs->fields["id"];
         $tmp->name = $rs->fields["name"];
         $tmp->logSize = $rs->fields["log_size"];
         $ret[] = $tmp;
         $rs->MoveNext();
     }
     return $ret;
     close_db($DB);
 }
开发者ID:bogus,项目名称:findik-web-amf,代码行数:22,代码来源:BTKTimestampHistoryService.php

示例13: getData

 /**
  * Retrieve all the records from the table
  * @return an array of VOTimeline
  */
 public function getData($searchKey = null)
 {
     //connect to the database.
     $DB = connect_db(false);
     //retrieve all rows
     $rs = $DB->Execute("SELECT * FROM btk_db_update ORDER BY id desc");
     $ret = array();
     while (!$rs->EOF) {
         $tmp = new VOBTKDbUpdate();
         $tmp->id = $rs->fields["id"];
         $tmp->updateId = $rs->fields["update_id"];
         $tmp->updateDate = $rs->fields["update_date"];
         $tmp->newRecordCount = $rs->fields["new_record_count"];
         $tmp->deletedRecordCount = $rs->fields["deleted_record_count"];
         $ret[] = $tmp;
         $rs->MoveNext();
     }
     return $ret;
     close_db($DB);
 }
开发者ID:bogus,项目名称:findik-web-amf,代码行数:24,代码来源:BTKDbUpdateService.php

示例14: getData

 /**
  * Retrieve all the records from the table
  * @return an array of VOTimeline
  */
 public function getData($searchKey = null)
 {
     //connect to the database.
     $DB = connect_db(false);
     //retrieve all rows
     $rs = $DB->Execute("SELECT * FROM btk_service_status ORDER BY id");
     $ret = array();
     while (!$rs->EOF) {
         $tmp = new VOTimeline();
         $tmp->id = $rs->fields["id"];
         $tmp->startDate = $rs->fields["start_date"];
         $tmp->endDate = $rs->fields["end_date"];
         $tmp->status = $rs->fields["status"];
         $tmp->label = $rs->fields["status"];
         $ret[] = $tmp;
         $rs->MoveNext();
     }
     return $ret;
     close_db($DB);
 }
开发者ID:bogus,项目名称:findik-web-amf,代码行数:24,代码来源:BTKTimelineService.php

示例15: mysqli_fetch_assoc

echo $val["id"];
?>
"><img src="img/del.png" alt="удалить">удалить</a></a></li>
</ul>
<h1><?php 
echo $val["name"];
?>
</h1>
<div class="article">
    <div>
        <span>Автор: <?php 
echo mysqli_fetch_assoc(mysqli_query($link, "SELECT name FROM `author` WHERE `id`=" . $val["author_id"]))["name"];
?>
</span>
        <span>&nbsp;&nbsp;&nbsp;&nbsp;Дата: <?php 
echo $val["date"];
?>
</span>
    </div>
    <div class="article-body">
        <?php 
echo $val["article"];
?>
    </div>

</div>
</body>
</html>
<?php 
close_db($link);
开发者ID:TTeRMiTT,项目名称:php2,代码行数:30,代码来源:article.php


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