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


PHP Database类代码示例

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


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


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