• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Database类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ShowMenuFiche

function ShowMenuFiche($p_dossier)
{
    $cn = new Database($p_dossier);
    $mod = "&ac=" . $_REQUEST['ac'];
    $str_dossier = dossier::get() . $mod;
    echo '<div class="lmenu">';
    echo '<TABLE>';
    echo '<TR><TD colspan="1" class="mtitle"  style="width:auto" >
    <A class="mtitle" HREF="?p_action=fiche&action=add_modele&fiche=modele&' . $str_dossier . '">' . _('Création') . '</A></TD>
    <TD><A class="mtitle" HREF="?p_action=fiche&' . $str_dossier . '">' . _('Recherche') . '</A></TD>
    </TR>';
    $Res = $cn->exec_sql("select fd_id,fd_label from fiche_def order by fd_label");
    $Max = Database::num_row($Res);
    for ($i = 0; $i < $Max; $i++) {
        $l_line = Database::fetch_array($Res, $i);
        printf('<TR><TD class="cell">
               <A class="mtitle" HREF="?p_action=fiche&action=modifier&fiche=%d&%s">%s</A></TD>
               <TD class="mshort">
               <A class="mtitle" HREF="?p_action=fiche&action=vue&fiche=%d&%s">Liste</A>
               </TD>
               </TR>', $l_line['fd_id'], $str_dossier, $l_line['fd_label'], $l_line['fd_id'], $str_dossier);
    }
    echo "</TABLE>";
    echo '</div>';
}
开发者ID:Kloadut,项目名称:noalyss_ynh,代码行数:25,代码来源:user_menu.php


示例2: parse

 /**
  *
  */
 public function parse(Database $database)
 {
     $this->addVendorInfo = $this->getGeneratorConfig()->getBuildProperty('addVendorInfo');
     $stmt = $this->dbh->query("SHOW TABLES");
     // First load the tables (important that this happen before filling out details of tables)
     $tables = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $name = $row[0];
         $table = new Table($name);
         $database->addTable($table);
         $tables[] = $table;
     }
     // Now populate only columns.
     foreach ($tables as $table) {
         $this->addColumns($table);
     }
     // Now add indexes and constraints.
     foreach ($tables as $table) {
         $this->addForeignKeys($table);
         $this->addIndexes($table);
         $this->addPrimaryKey($table);
         if ($this->addVendorInfo) {
             $this->addTableVendorInfo($table);
         }
     }
 }
开发者ID:yasirgit,项目名称:afids,代码行数:29,代码来源:MysqlSchemaParser.php


示例3: __construct

 function __construct($Owner)
 {
     parent::__construct();
     $this->pack_start(new GtkLabel(latin1(' Tipo de Endereço: ')), false);
     $this->store = new GtkListStore(TYPE_STRING, TYPE_LONG);
     $this->pack_start($this->combobox = new GtkComboBox($this->store));
     $this->combobox->pack_start($cell = new GtkCellRendererText());
     $this->combobox->set_attributes($cell, 'text', 0);
     $this->combobox->connect('changed', array($this, 'tipo_endereco_changed'));
     $this->show_all();
     /*
      * preenche lista
      */
     $db = new Database($Owner, true);
     if (!$db->link) {
         return;
     }
     /*
      * Tipo de Endereco
      */
     if (!$db->multi_query('SELECT * FROM Vw_Tipos_Endereco')) {
         return;
     }
     $this->store->clear();
     unset($this->it);
     while ($line = $db->line()) {
         $row = $this->store->append();
         $this->store->set($row, 0, $line['Descricao'], 1, $line['Id']);
         $this->it[$line['Id']] = $row;
     }
 }
开发者ID:eneiasramos,项目名称:xmoney,代码行数:31,代码来源:tipo_endereco.php


示例4: parse

 /**
  *
  */
 public function parse(Database $database, Task $task = null)
 {
     $stmt = $this->dbh->query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME <> 'dtproperties'");
     // First load the tables (important that this happen before filling out details of tables)
     $tables = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $name = $row[0];
         if ($name == $this->getMigrationTable()) {
             continue;
         }
         $table = new Table($name);
         $table->setIdMethod($database->getDefaultIdMethod());
         $database->addTable($table);
         $tables[] = $table;
     }
     // Now populate only columns.
     foreach ($tables as $table) {
         $this->addColumns($table);
     }
     // Now add indexes and constraints.
     foreach ($tables as $table) {
         $this->addForeignKeys($table);
         $this->addIndexes($table);
         $this->addPrimaryKey($table);
     }
     return count($tables);
 }
开发者ID:norfil,项目名称:Propel2,代码行数:30,代码来源:MssqlSchemaParser.php


示例5: queue

 static function queue($params)
 {
     $db = new Database();
     # MailQueue class can be created
     $script = "INSERT INTO MailQueue SET `type` = :type,\n                    senderName = :senderName,\n                    senderEmail = :senderEmail,\n                    receiverName = :receiverName,\n                    receiverEmail = :receiverEmail,\n                    cc = :cc,\n                    bcc = :bcc,\n                    subject = :subject,\n                    body = :body";
     return $db->executeUpdate($script, $params);
 }
开发者ID:arjayads,项目名称:php-simple-auth,代码行数:7,代码来源:Emailer.php


示例6: getEquip

function getEquip()
{
    $db = new Database();
    $link = $db->connect();
    $result = $db->select($link, 'equip_type');
    return $result;
}
开发者ID:xolodok373,项目名称:tit.biz,代码行数:7,代码来源:crudModel.php


示例7: compile

	/**
	 * Compile the SQL query and return it.
	 *
	 * @param   object  Database instance
	 * @return  string
	 */
	public function compile(Database $db)
	{
		// Start a deletion query
		$query = 'DELETE FROM '.$db->quote_table($this->_table);

		if ( ! empty($this->_where))
		{
			// Add deletion conditions
			$query .= ' WHERE '.$this->_compile_conditions($db, $this->_where);
		}

		if ( ! empty($this->_order_by))
		{
			// Add sorting
			$query .= ' '.$this->_compile_order_by($db, $this->_order_by);
		}

		if ($this->_limit !== NULL && substr($db->_db_type, 0, 6) !== 'sqlite')
		{
			// Add limiting
			$query .= ' LIMIT '.$this->_limit;
		}

		return $query;
	}
开发者ID:nasumi,项目名称:fuel,代码行数:31,代码来源:delete.php


示例8: getDatosClteClave

 function getDatosClteClave($clave)
 {
     $con = new Database();
     $query = "select * from clientes_todos where clave_agrupadora = {$clave} order by alta desc limit 1";
     $r = $con->Fetch($query);
     return $r;
 }
开发者ID:jesusmisael,项目名称:CREANDOSISTEMAS_PLD,代码行数:7,代码来源:mAutocomplete.php


示例9: compile

 /**
  * Compile the SQL partial for a JOIN statement and return it.
  *
  * @param   object  Database instance
  * @return  string
  */
 public function compile(Database $db)
 {
     if ($this->_type) {
         $sql = strtoupper($this->_type) . ' JOIN';
     } else {
         $sql = 'JOIN';
     }
     // Quote the table name that is being joined
     $sql .= ' ' . $db->quote_table($this->_table);
     if (!empty($this->_using)) {
         // Quote and concat the columns
         $sql .= ' USING (' . implode(', ', array_map(array($db, 'quote_column'), $this->_using)) . ')';
     } else {
         $conditions = array();
         foreach ($this->_on as $condition) {
             // Split the condition
             list($c1, $op, $c2) = $condition;
             if ($op) {
                 // Make the operator uppercase and spaced
                 $op = ' ' . strtoupper($op);
             }
             // Quote each of the columns used for the condition
             $conditions[] = $db->quote_column($c1) . $op . ' ' . $db->quote_column($c2);
         }
         // Concat the conditions "... AND ..."
         $sql .= ' ON (' . implode(' AND ', $conditions) . ')';
     }
     return $sql;
 }
开发者ID:reznikds,项目名称:Reznik,代码行数:35,代码来源:join.php


示例10: testSelect

 function testSelect()
 {
     $db = new Database();
     $sql = "SELECT COUNT(*) AS count FROM members";
     $result = $db->select($sql);
     $this->assertTrue($result[0]["count"] === 0);
 }
开发者ID:soon0009,项目名称:membership-database,代码行数:7,代码来源:database_test.php


示例11: getBooksByIdUser

 function getBooksByIdUser($idUser, $idBook)
 {
     $db = new Database();
     $query = "SELECT * FROM books b LEFT JOIN users u  ON b.fk_owner = u.user_id WHERE b.id_book ='{$idBook}' AND b.fk_user='{$idUser}'";
     $arrayBooks = $db->select($query);
     return $this->arrayBooks = $arrayBooks;
 }
开发者ID:loi219,项目名称:Shared-library,代码行数:7,代码来源:GetBook.php


示例12: __construct

 function __construct($Owner)
 {
     parent::__construct();
     $this->pack_start(new GtkLabel(' Fornecedor: '), false);
     $completion = new GtkEntryCompletion();
     $completion->set_model($this->store = new GtkListStore(TYPE_STRING, TYPE_LONG));
     $completion->set_text_column(0);
     $completion->pack_start($cell = new GtkCellRendererText());
     $completion->set_attributes($cell, 'text', 1);
     $completion->connect('match-selected', array($this, 'fornecedor_selected'));
     $this->pack_start($this->entry = new GtkEntry());
     $this->entry->set_completion($completion);
     $this->show_all();
     /*
      * preenche lista
      */
     $db = new Database($Owner, true);
     if (!$db->link) {
         return;
     }
     /*
      * Fornecedores
      */
     if (!$db->multi_query('SELECT * FROM Vw_Fornecedores')) {
         return;
     }
     $this->store->clear();
     unset($this->it);
     while ($line = $db->line()) {
         $row = $this->store->append();
         $this->store->set($row, 0, $line['Nome'], 1, $line['Id']);
         $this->it[$line['Id']] = $row;
     }
 }
开发者ID:eneiasramos,项目名称:xmoney,代码行数:34,代码来源:fornecedores.php


示例13: getAppointmentPatientList

 function getAppointmentPatientList($patientName, $hosiptal, $appdate)
 {
     $dbConnection = new Database();
     $sql = "SELECT * from appointment where patientName LIKE :patientName and hosiptalid = :hosiptalid and appointementdate = :appdate and status = 'N'";
     //   echo $sql;
     //    echo $patientName;
     try {
         $db = $dbConnection->getConnection();
         $stmt = $db->prepare($sql);
         $stmt->bindValue("patientName", "%" . $patientName . "%", PDO::PARAM_STR);
         $stmt->bindParam("hosiptalid", $hosiptal);
         $stmt->bindParam("appdate", $appdate);
         $stmt->execute();
         $appointmentDetails = $stmt->fetchAll(PDO::FETCH_OBJ);
         $db = null;
         //$_SESSION['userDetails'] = $userDetails;
         // echo $stmt->debugDumpParams();
         //  print_r($userDetails);
         return $appointmentDetails;
     } catch (PDOException $e) {
         echo '{"error":{"text":' . $e->getMessage() . '}}';
     } catch (Exception $e1) {
         echo '{"error11":{"text11":' . $e1->getMessage() . '}}';
     }
 }
开发者ID:sasanka10,项目名称:CGHealthCare,代码行数:25,代码来源:PatientData.php


示例14: main

function main($post_data)
{
    $db = new Database();
    if (!$db->connect()) {
        exit_with_error('DatabaseConnectionFailure');
    }
    $report = json_decode($post_data, true);
    verify_slave($db, $report);
    $commits = array_get($report, 'commits', array());
    foreach ($commits as $commit_info) {
        if (!array_key_exists('repository', $commit_info)) {
            exit_with_error('MissingRepositoryName', array('commit' => $commit_info));
        }
        if (!array_key_exists('revision', $commit_info)) {
            exit_with_error('MissingRevision', array('commit' => $commit_info));
        }
        require_format('Revision', $commit_info['revision'], '/^[A-Za-z0-9 \\.]+$/');
        if (array_key_exists('author', $commit_info) && !is_array($commit_info['author'])) {
            exit_with_error('InvalidAuthorFormat', array('commit' => $commit_info));
        }
    }
    $db->begin_transaction();
    foreach ($commits as $commit_info) {
        $repository_id = $db->select_or_insert_row('repositories', 'repository', array('name' => $commit_info['repository']));
        if (!$repository_id) {
            $db->rollback_transaction();
            exit_with_error('FailedToInsertRepository', array('commit' => $commit_info));
        }
        $author = array_get($commit_info, 'author');
        $committer_id = NULL;
        if ($author) {
            $account = array_get($author, 'account');
            $committer_query = array('repository' => $repository_id, 'account' => $account);
            $committer_data = $committer_query;
            $name = array_get($author, 'name');
            if ($name) {
                $committer_data['name'] = $name;
            }
            $committer_id = $db->update_or_insert_row('committers', 'committer', $committer_query, $committer_data);
            if (!$committer_id) {
                $db->rollback_transaction();
                exit_with_error('FailedToInsertCommitter', array('committer' => $committer_data));
            }
        }
        $parent_revision = array_get($commit_info, 'parent');
        $parent_id = NULL;
        if ($parent_revision) {
            $parent_commit = $db->select_first_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $parent_revision));
            if (!$parent_commit) {
                $db->rollback_transaction();
                exit_with_error('FailedToFindParentCommit', array('commit' => $commit_info));
            }
            $parent_id = $parent_commit['commit_id'];
        }
        $data = array('repository' => $repository_id, 'revision' => $commit_info['revision'], 'parent' => $parent_id, 'order' => array_get($commit_info, 'order'), 'time' => array_get($commit_info, 'time'), 'committer' => $committer_id, 'message' => array_get($commit_info, 'message'), 'reported' => true);
        $db->update_or_insert_row('commits', 'commit', array('repository' => $repository_id, 'revision' => $data['revision']), $data);
    }
    $db->commit_transaction();
    exit_with_success();
}
开发者ID:reaven15,项目名称:webkit,代码行数:60,代码来源:report-commits.php


示例15: verify

 /**
  * Function to support the services/data_cleaner/verify web-service. 
  * Receives a list of proposed records and applies verification rules to them, then
  * returns a list of verification notices.
  * Input is provided in the $_GET or $_POST data sent to the method as follows:
  * auth_token - read authorisation token
  * nonce - read nonce
  * sample - Provides details of the sample being verified. If verifying a list
  * of records from different places or dates then the sample entry can be ommitted or only partially
  * filled-in with the missing information provided on a record by record bases. A JSON formatted
  * object with entries for sample:survey_id, sample:date, sample:entered_sref and sample:entered_sref_system, plus 
  * optional sample:geom (WKT format).
  * occurrences - JSON format, provide an array of the occurrence record to verify. Each record is an object
  * with occurrence:taxa_taxon_list_id, an optional stage plus any of the values for the sample which need to be 
  * specified on a record by record bases. I.e. provide sample:date if the sample information sent
  * does not include a date, or a date is included but this record is for a different date.
  * rule_types - JSON formatted array of the rule types to run. If not provided, then all rule types are run.
  * E.g. ["WithoutPolygon","PeriodWithinYear"] to run just without polygon and period within year checks.
  * @return JSON A JSON array containing a list of notifications. Each notification is a JSON
  * object, with taxa_taxon_list_id and message properties.
  */
 public function verify()
 {
     // authenticate requesting website for this service
     $this->authenticate('read');
     if (isset($_REQUEST['sample'])) {
         $sample = json_decode($_REQUEST['sample'], true);
     }
     if (isset($_REQUEST['occurrences'])) {
         $occurrences = json_decode($_REQUEST['occurrences'], true);
     }
     if (empty($sample) || empty($occurrences)) {
         $this->response = 'Invalid parameters';
     } else {
         $db = new Database();
         // Create an empty template table
         $db->query("select * into temporary occdelta from cache_occurrences limit 0;");
         try {
             $this->prepareOccdelta($db, $sample, $occurrences);
             $r = $this->runRules($db);
             $db->query('drop table occdelta');
             $this->content_type = 'Content-Type: application/json';
             $this->response = json_encode($r);
         } catch (Exception $e) {
             $db->query('drop table occdelta');
             $this->response = "Query failed";
             error::log_error('Error occurred calling verification rule service', $e);
         }
     }
     $this->send_response();
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:51,代码来源:data_cleaner.php


示例16: setSession

 public function setSession()
 {
     session_start();
     $page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : '';
     if ($page_mode == 'login') {
         $this->password = sha1($_POST['password']);
         $this->userName = $_POST['userName'];
         try {
             $dbh = new Database();
             $data = array(':userName' => $this->userName, ':password' => $this->password);
             $sql = "SELECT * FROM {$this->tableName} WHERE user_name=:userName AND password = :password";
             $sth = $dbh->prepare($sql);
             $sth->execute($data);
             $sth->setFetchMode(PDO::FETCH_ASSOC);
             $row = $sth->fetch();
         } catch (PDOException $e) {
             echo "I'm sorry, Dave. I'm afraid I can't do that.";
             file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
             echo $e->getMessage();
         }
         if (!$row) {
             $this->errorString = 'Clave o nombre de usuario incorrectos';
         } else {
             $_SESSION['userId'] = $row["{$this->tableId}"];
             $_SESSION['userName'] = $row['user_name'];
             header('Location: index.php');
         }
     }
 }
开发者ID:rfc1483,项目名称:padelmvc,代码行数:29,代码来源:login.php


示例17: delete

	function delete()
	{
		$db = new Database();
		$sql = sprintf("delete from order_props where id = %d", $this->id);
		$db->executeSQL($sql, __FILE__, __LINE__, false);
		$db->close();
	}
开发者ID:njassim,项目名称:SOHO_REPRO,代码行数:7,代码来源:order_prop.class.php


示例18: compile

 /**
  * Compile the SQL query and return it.
  *
  * @param   object  Database instance
  * @return  string
  */
 public function compile(Database $db)
 {
     $query = 'ALTER TABLE ' . $db->quote_table($this->_table) . ' ';
     $lines = array();
     if ($this->_name !== NULL) {
         $lines[] = 'RENAME TO ' . $db->quote_table($this->_name) . '; ';
     }
     if (count($this->_add_columns) > 0) {
         $columns = array();
         $sql = $query . 'ADD(';
         foreach ($this->_add_columns as $name => $params) {
             $columns[] = Database_Query_Builder::compile_column($name, $params);
         }
         $sql .= implode($columns, ',') . '); ';
         $lines[] = $sql;
     }
     if (count($this->_modify_columns) > 0) {
         $columns = array();
         $sql = $query . 'MODIFY(';
         foreach ($this->_modify_columns as $name => $params) {
             $columns[] = Database_Query_Builder::compile_column($name, $params);
         }
         $sql .= implode($columns, ',') . '); ';
         $lines[] = $sql;
     }
     if (count($this->_drop_columns) > 0) {
         foreach ($this->_drop_columns as $name) {
             $drop = new Database_Query_Builder_Drop('column', $name);
             $lines[] = $drop->compile() . ';';
         }
     }
 }
开发者ID:joelpittet,项目名称:database,代码行数:38,代码来源:alter.php


示例19: testGetCustomForms

 /**
  * Tests the get_custom_forms method
  *
  * @test
  */
 public function testGetCustomForms()
 {
     // Database instance for the test
     $db = new Database();
     // The record count should be the same since get_custom_forms() has no predicates
     $this->assertEquals($db->count_records('form'), customforms::get_custom_forms()->count());
 }
开发者ID:neumicro,项目名称:Ushahidi_Web_Dev,代码行数:12,代码来源:Customforms_Test.php


示例20: validate

    public static function validate($connection)
    {
        if (isset($_COOKIE['authenticated'])) {
            $userData = explode('##', $_COOKIE['authenticated']);
            $email = $userData[0];
            $saltedEmail = $userData[1];
            $db = new Database($connection);
            $userData = $db->query('SELECT * 
											FROM users 
											WHERE email = :email', array(':email' => $email));
            if (isset($userData['data'][0])) {
                $salt = $userData['data'][0]['salt'];
                $newlySaltedEmail = hash('sha512', $salt . $email);
                if ($newlySaltedEmail == $saltedEmail) {
                    # Cookie is correct
                    return true;
                } else {
                    # Password niet correct
                    return false;
                }
            } else {
                # User niet gevonden
                return false;
            }
        } else {
            #Cookie niet geset
            return false;
        }
    }
开发者ID:gurbuzhasan,项目名称:web-backend,代码行数:29,代码来源:User.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DatabaseBase类代码示例发布时间:2022-05-23
下一篇:
PHP DataValidator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap