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


PHP database类代码示例

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


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

示例1: frontend

 public function frontend($variables)
 {
     #Syntax = Number of results to display
     require_once 'classes/database.php';
     global $classDatabase;
     if (!isset($classDatabase)) {
         $classDatabase = new database();
     }
     global $classPageInfo;
     //POST REPORT THREAD
     //Only post if a $_GET['et'] is given
     if (isset($_POST["et"])) {
         echo "<div class='reportPost postInformation'>";
         $classDatabase->psReportsInsertETBoolAndPostID($_POST["et"], $_POST["id"]);
         echo "</div>";
     }
     //VIEW BOARD
     $threads = $classDatabase->psThreadsSelectIDTitleLinkTextCreateTimeUserIDPinnedTotalRepliesWhereBoardIDEqualsOrderByorderPointINLIMIT($variables, $classPageInfo->pageNum, $classPageInfo->boardID);
     $threadIDs = $threads[0];
     $threadTitles = $threads[1];
     $threadLinks = $threads[2];
     $threadTexts = $threads[3];
     $threadCreateTimes = $threads[4];
     $threadUserIDs = $threads[5];
     $threadPinned = $threads[6];
     $threadTotalReplies = $threads[7];
     echo "<div class='boardView'>";
     for ($i = 0; $i < count($threadIDs); ++$i) {
         echo "<div class='boardView thread'>" . "<div class='boardView preview'><a href='" . $threadLinks[$i] . "'><img src='/resources/icons/link.png'></a></div>" . "<div class='boardView info'>" . "<div class='boardView title'><a href='/boards/" . $classPageInfo->boardTitle . "/thread/" . $threadIDs[$i] . "'>" . $threadTitles[$i] . "</a></div>" . "<div class='boardView moreInfo'>" . "<div class='boardView user'>Posted by - " . $classDatabase->psUserSelectUsernameWhereIDEquals($threadUserIDs[$i]) . "</div>" . "<div class='boardView id'>Thread ID - " . $threadIDs[$i] . "</div>" . "<div class='boardView date'>Posted on - " . $threadCreateTimes[$i] . "</div>" . "<div class='boardView replies'>" . $threadTotalReplies[$i] . " replies</div>" . "<div class='boardView options'>Options" . "<div class='boardView optionsMenu'>" . "Options: <BR>" . "<form method='post' action=''?''><input type='hidden' name='et' value='1'><input type='hidden' name='id' value='" . $threadIDs[$i] . "'><input type='submit' value='Report Post'></form><BR>" . "</div>" . "</div>" . "</div></div></div>";
     }
     echo "</div>";
 }
开发者ID:ketchupmonki,项目名称:soylentblack,代码行数:32,代码来源:displayBoard.php

示例2: gc

 public function gc($maxlifetime)
 {
     $db = new database();
     $db->query("DELETE FROM tbl_session\n                  WHERE session_lastaccesstime < DATE_SUB(NOW(),\n                  INTERVAL " . $maxlifetime . " SECOND)");
     $db->execute();
     return true;
 }
开发者ID:nfreader,项目名称:baseline,代码行数:7,代码来源:session.php

示例3: update

 public function update($user_id)
 {
     $database = new database();
     $query = "update users set email = '{$this->email}'," . "username = '{$this->username}'," . "profile_pic = '{$this->profilePic}'," . "job = '{$this->job}'," . "address = '{$this->address}'," . "gender = '{$this->gender}'" . "WHERE user_id={$user_id}";
     $result = $database->performQuery($query);
     return $result ? TRUE : FALSE;
 }
开发者ID:samyasin,项目名称:noSoGo_102,代码行数:7,代码来源:user.php

示例4: __construct

 public function __construct()
 {
     //connect to the database if not connected
     if (!$this->db) {
         require_once "resources/classes/database.php";
         $database = new database();
         $database->connect();
         $this->db = $database->db;
     }
     //add multi-lingual support
     $language = new text();
     $text = $language->get();
     //get the ringback types
     $sql = "select * from v_vars ";
     $sql .= "where var_cat = 'Defaults' ";
     $sql .= "and var_name LIKE '%-ring' ";
     $sql .= "order by var_name asc ";
     $prep_statement = $this->db->prepare(check_sql($sql));
     $prep_statement->execute();
     $ringbacks = $prep_statement->fetchAll(PDO::FETCH_NAMED);
     unset($prep_statement, $sql);
     foreach ($ringbacks as $ringback) {
         $ringback = $ringback['var_name'];
         $label = $text['label-' . $ringback];
         if ($label == "") {
             $label = $ringback;
         }
         $ringback_list[$ringback] = $label;
     }
     $this->ringbacks = $ringback_list;
     unset($ringback_list);
     //get the default_ringback label
     /*
     $sql = "select * from v_vars where var_name = 'ringback' ";
     $prep_statement = $this->db->prepare(check_sql($sql));
     $prep_statement->execute();
     $result = $prep_statement->fetch();
     unset ($prep_statement, $sql);
     $default_ringback = (string) $result['var_value'];
     $default_ringback = preg_replace('/\A\$\${/',"",$default_ringback);
     $default_ringback = preg_replace('/}\z/',"",$default_ringback);
     #$label = $text['label-'.$default_ringback];
     #if($label == "") {
     	$label = $default_ringback;
     #}
     $this->default_ringback_label = $label;
     unset($results, $default_ringback, $label);
     */
     //get music on hold	and recordings
     if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/music_on_hold')) {
         require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php";
         $music = new switch_music_on_hold();
         $this->music_list = $music->get();
     }
     if (is_dir($_SERVER["PROJECT_ROOT"] . '/app/recordings')) {
         require_once "app/recordings/resources/classes/switch_recordings.php";
         $recordings = new switch_recordings();
         $this->recordings_list = $recordings->list_recordings();
     }
 }
开发者ID:powerpbx,项目名称:fusionpbx,代码行数:60,代码来源:ringbacks.php

示例5: get

    public static function get($id = null)
    {
        $database = new database();
        $q = '
			SELECT
				' . RUDE_DATABASE_TABLE_SPECIALTIES . '.*,
				' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_NAME . ' AS faculty_name,
				' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_SHORTNAME . ' AS faculty_shortname,
				' . RUDE_DATABASE_TABLE_QUALIFICATIONS . '.' . RUDE_DATABASE_FIELD_NAME . ' AS qualification_name
			FROM
				' . RUDE_DATABASE_TABLE_SPECIALTIES . '
			LEFT JOIN
				' . RUDE_DATABASE_TABLE_FACULTIES . ' ON ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_FACULTY_ID . ' = ' . RUDE_DATABASE_TABLE_FACULTIES . '.' . RUDE_DATABASE_FIELD_ID . '
			LEFT JOIN
				' . RUDE_DATABASE_TABLE_QUALIFICATIONS . ' ON ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_QUALIFICATION_ID . ' = ' . RUDE_DATABASE_TABLE_QUALIFICATIONS . '.' . RUDE_DATABASE_FIELD_ID . '
		';
        if ($id !== null) {
            $q .= PHP_EOL . 'WHERE ' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_ID . ' = ' . (int) $id;
        }
        $q .= '
			GROUP BY
				' . RUDE_DATABASE_TABLE_SPECIALTIES . '.' . RUDE_DATABASE_FIELD_ID;
        $database->query($q);
        if ($id !== null) {
            return $database->get_object();
        }
        return $database->get_object_list();
    }
开发者ID:ThisNameWasFree,项目名称:rude-univ,代码行数:28,代码来源:rude-specialties.php

示例6: getProximosCursos

 public static function getProximosCursos()
 {
     $db = new database();
     $sql = "SELECT * FROM cursos WHERE id=3";
     $db->query($sql);
     return $db->cargaMatriz();
 }
开发者ID:InmaGutierrez,项目名称:webCoding,代码行数:7,代码来源:model.php

示例7: login

 public function login()
 {
     $database = new database();
     if ($database->get_type() == 'mysql') {
         $db_arr = $database->connect();
         if ($db_arr[0] == 1) {
             return array(1, $db_arr[1]);
         }
         $this->db = $db_arr[1];
         // continue implementing login check
         $this->username = $this->db->escape_string(stripslashes($this->username));
         $this->password = $this->db->escape_string(stripslashes($this->password));
         $getuserquery = "SELECT * FROM user WHERE user_name='" . $this->username . "' AND user_password='" . $this->password . "'";
         $getuserresult = $this->db->query($getuserquery);
         $getuserresult_count = $getuserresult->num_rows;
         if ($getuserresult_count == 0) {
             $this->authstatus = false;
             return array(2, 'Username and password incorrect.');
         } elseif ($getuserresult_count == 1) {
             $this->authstatus = true;
             return array(0, $this->authstatus);
         } else {
             return array(2, 'MySQL returning weird things.');
         }
     } elseif ($database->get_type() == 'sqlite') {
         $db_arr = $database->connect_sqlite();
         $this->db = $db_arr;
         // do things that have yet to be decided
     }
 }
开发者ID:pluma-lms,项目名称:pluma-lms-php,代码行数:30,代码来源:user_login.php

示例8: DLog

function DLog($api_call, $securityLevel, $message, $account_id)
{
    $database = new database();
    $sql = "INSERT INTO Log(Api_call, ReqSecurityLevel, Comment, ID) VALUES ({$api_call}, {$securityLevel}, {$message}, {$account_id})";
    mysqli_query($database->getConnection(), $sql);
    $database->close();
}
开发者ID:TheNightWolf,项目名称:Hephaestus,代码行数:7,代码来源:DLog.php

示例9: __construct

    function __construct(database $db, user $user)
    {
        $this->db =& $db;
        $this->user =& $user;
        $usertype = Kit::GetParam('usertype', _SESSION, _INT, 0);
        $this->groupid = Kit::GetParam('groupid', _REQUEST, _INT, 0);
        // Do we have a user group selected?
        if ($this->groupid != 0) {
            // If so then we will need to get some information about it
            $SQL = <<<END
\t\t\tSELECT \tgroup.GroupID,
\t\t\t\t\tgroup.Group
\t\t\tFROM `group`
\t\t\tWHERE groupID = %d
END;
            $SQL = sprintf($SQL, $this->groupid);
            if (!($results = $db->query($SQL))) {
                trigger_error($db->error());
                trigger_error(__("Can not get Group information."), E_USER_ERROR);
            }
            $aRow = $db->get_assoc_row($results);
            $this->group = $aRow['Group'];
        }
        // Include the group data classes
        include_once 'lib/data/usergroup.data.class.php';
    }
开发者ID:abbeet,项目名称:server39,代码行数:26,代码来源:group.class.php

示例10: __save

 /**
  * Fetches hashed data from db and put into instance
  */
 private function __save()
 {
     $class = $this->class;
     $database = new database($class::$database);
     if ($this->get_attributes()) {
         $columns = "(`{$class::$entity_id_column}`, `{$class::$key_column}`, `{$class::$value_column}`, `date_added`, `date_updated`)";
         $placeholders = $values = $duplicate_keys = array();
         foreach ($this->get_attributes() as $key => $value) {
             $placeholders[] = "(%d, %s, %s, NOW(), NOW())";
             $values[] = $this->entity_id;
             $values[] = $key;
             $values[] = $value;
             $duplicate_keys[] = "`{$class::$value_column}` = VALUES(`{$class::$value_column}`)";
         }
         $duplicate_keys[] = '`date_updated` = VALUES(`date_updated`)';
         $database->query("INSERT INTO {$class::$table} {$columns} VALUES " . implode(', ', $placeholders) . " ON DUPLICATE KEY UPDATE " . implode(', ', $duplicate_keys), $values);
     }
     if ($unset_keys = array_diff($this->original_keys, array_keys($this->get_attributes()))) {
         // we unset something
         print_r(array($this->entity_id, $unset_keys));
         database::enable_log();
         $database->query("DELETE FROM {$class::$table} WHERE `{$class::$entity_id_column}` = %d AND `{$class::$key_column}` IN (%s)", array($this->entity_id, $unset_keys));
     }
     return true;
 }
开发者ID:revcozmo,项目名称:dating,代码行数:28,代码来源:entity_hash.php

示例11: getFondos

 public static function getFondos()
 {
     $db = new database();
     $sql = "select subtitulos,img_cursos from cursos WHERE id<=4;";
     $db->query($sql);
     return $db->cargaMatriz();
 }
开发者ID:InmaGutierrez,项目名称:webCoding,代码行数:7,代码来源:model.php

示例12: details

 public function details()
 {
     // details combines seeing with editing
     $id = $_GET['id'];
     $columns = array('nom, prenom, nom_khmer, prenom_khmer, sex_id,  active_id');
     $neat_columns = array('Last Name', 'First Name', 'Last Name Khmer', 'First Name Khmer', 'Genre', 'Active', 'Update', 'Delete');
     $form = array('action' => '?controller=teachers&action=update&id=' . $id, 'div' => "class='solitary_input'", 'div_button' => "class='submit_button1'", 'action_links' => array(1 => array('delete', '?controller=teachers&action=delete&id=')), 'method' => 'post', 'id' => 'top_form', 'elements' => array(1 => array('text' => 'nom'), 2 => array('text' => 'prenom'), 3 => array('text' => 'nom_khmer'), 4 => array('text' => 'prenom_khmer'), 5 => array('drop_down' => 'sex_id'), 6 => array('drop_down' => 'active_id'), 7 => array('submit' => 'update')));
     $connection = new database();
     $table = new simple_table_ops();
     $sql = 'SELECT sex_id, sex FROM sexes';
     $sex_result = $connection->query($sql);
     $sql2 = 'SELECT active_id, active FROM actives';
     $active_result = $connection->query($sql2);
     $drop_down = array('sex_id' => array('sex' => $sex_result), 'active_id' => array('active' => $active_result));
     $table->set_table_name('teachers');
     $table->set_id_column('teacher_id');
     $table->set_table_column_names($columns);
     $table->set_html_table_column_names($neat_columns);
     $table->set_values_form();
     // set values found in database into form elements when building top_form
     $table->set_drop_down($drop_down);
     $table->set_form_array($form);
     $content = '<table>';
     $content .= $table->details();
     $content .= '</table>';
     $output['content'] = $content;
     return $output;
 }
开发者ID:dagasaga,项目名称:css,代码行数:28,代码来源:teachersController.php

示例13: upload

function upload($file_name, $file_type, $file_path, $file_title)
{
    if (!empty($_FILES["fileUpload"]) && !empty($_POST["imgTitle"])) {
        $file_type = $_FILES['fileUpload']['type'];
        $file_title = $_POST["imgTitle"];
        if ($file_type == "image/gif") {
            $file_path = $_FILES['fileUpload']['tmp_name'];
            $file_name = $_FILES['fileUpload']['name'];
            $new_path = "upload/img/" . $file_name;
            $file_error = $_FILES["fileUpload"]["error"];
            if ($file_error == 0 && move_uploaded_file($file_path, $new_path)) {
                $sql = "INSERT INTO gif.images (`title_img`, `name_img`, `id_user`) VALUES ('{$file_title}','{$file_name}', '0');";
                $upload = new database();
                $upload->connect();
                $query = $upload->query($sql);
                if (!empty($query)) {
                    $success = "Upload file và ghi dư liệu thành công.";
                    return $success;
                } else {
                    $success = "Upload file thành công.";
                    return $success;
                }
            }
            return $file_error;
        } else {
            $error = "File không đúng định dạng GIF";
            return $error;
        }
    }
}
开发者ID:lionlone,项目名称:gif,代码行数:30,代码来源:upload.php

示例14: adlib

function adlib($id, $type)
{
    // create adlib xml basic structure
    $XML = new simpleXmlElement("<?xml version='1.0' encoding='utf-8'?><adlibXML xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='http://www.adlibsoft.com/adlibXML.xsd' />");
    echoall("Start Adlib XML export");
    echoall("Connect database");
    $daba = new database();
    $daba->connect("localhost", "iggmp", "1s87J37r0");
    if ($daba->select("thesaurus")) {
        echoall("Database connected");
    } else {
        die("***ERROR - Database connection failed");
    }
    $termType = thesaurus::get_name($id);
    echoall("Starte bei <b>'" . thesaurus::get_name($id) . "'</b>");
    //------------------------------------------------------------------------------
    // create recordList
    xml_insert($XML, new simpleXmlElement("<recordList />"));
    // insert records in recordList
    $subXml = _subtree($id, $termType);
    if ($subXml) {
        xml_insert($XML->recordList, $subXml);
    }
    echoall("XML export completed<hr>");
    echoall($XML);
    return $XML->asXML();
}
开发者ID:nibble-arts,项目名称:openthesaurus,代码行数:27,代码来源:adlib.php

示例15: get_db

 public function get_db()
 {
     $database = new database();
     $dbtype = $database->get_type();
     if ($dbtype == 'mysql') {
         $db_arr = $database->connect();
         if ($db_arr[0] == 1) {
             return array(1, $db_arr[1]);
         }
         $this->db = $db_arr[1];
         $get_query = "SELECT * FROM user WHERE user_name='" . $this->username . "'";
         $get_result = $this->db->query($get_query);
         $get_result_arr = $get_result->fetch_assoc();
         $get_result_count = $get_result->num_rows;
         if ($get_result_count != 1) {
             return array(2, 'Name not found');
         }
     } elseif ($dbtype == 'sqlite') {
         $db_arr = $database->connect_sqlite();
         $this->db = $db_arr;
         // to be implemented
     }
     $this->id = $get_result_arr['user_id'];
     $this->username = $get_result_arr['user_name'];
     $this->email = $get_result_arr['user_email'];
     $this->groupname = $this->group_id_to_name($get_result_arr['user_group']);
     $this->firstname = $get_result_arr['first_name'];
     $this->middlename = $get_result_arr['middle_name'];
     $this->lastname = $get_result_arr['last_name'];
 }
开发者ID:pluma-lms,项目名称:pluma-lms-php,代码行数:30,代码来源:user.php


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