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


PHP Connection::close方法代码示例

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


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

示例1: tearDown

 protected function tearDown()
 {
     if ($this->_db) {
         $this->_db->close();
     }
     $this->destroyApplication();
 }
开发者ID:kaneghost,项目名称:yii2Advansed,代码行数:7,代码来源:DatabaseTestCase.php

示例2: tearDown

 protected function tearDown()
 {
     parent::tearDown();
     if ($this->db) {
         $this->db->close();
     }
     $this->destroyApplication();
 }
开发者ID:rajanishtimes,项目名称:basicyii,代码行数:8,代码来源:DbManagerTestCase.php

示例3: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     static::runConsoleAction('migrate/down', ['migrationPath' => '@yii/log/migrations/', 'interactive' => false]);
     if (static::$db) {
         static::$db->close();
     }
     Yii::$app = null;
     parent::tearDownAfterClass();
 }
开发者ID:howq,项目名称:yii2,代码行数:9,代码来源:DbTargetTest.php

示例4: search

 public static function search(array $input)
 {
     $connection = new Connection(['dsn' => 'mysql:host=localhost;dbname=work', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8']);
     $connection->open();
     /**запрос выбирает имя сети, агенства и сумму
      * с группировкой ао агенству и "ИТОГО"
      * из подзапроса суммы с границами по датам.
      * COALESCE() меняет сумму NULL на 0
      */
     $sql = 'SELECT agency_network.agency_network_name, agency.agency_name, COALESCE(sum(t.amount),0) AS sum
             FROM agency_network
             RIGHT JOIN agency
             ON agency_network.agency_network_id = agency.agency_network_id
             LEFT JOIN
               (SELECT amount, date, agency_id
               FROM billing WHERE date BETWEEN :startdate AND :enddate) t
                    ON t.agency_id=agency.agency_id
             GROUP BY agency_name WITH ROLLUP;';
     /*Привязываем параметры с датами, для исключения иньекций*/
     $command = $connection->createCommand($sql)->bindParam(':startdate', $startdate)->bindParam(':enddate', $enddate);
     $startdate = $input[date1];
     $enddate = $input[date2];
     $result = $command->queryAll();
     $connection->close();
     return $result;
 }
开发者ID:nvs-nvs,项目名称:yii2-test-homework,代码行数:26,代码来源:DatabaseSearch.php

示例5: close

 public function close()
 {
     if ($this->pdo !== null) {
         $this->_transaction = null;
     }
     parent::close();
 }
开发者ID:edgardmessias,项目名称:yii2-firebird,代码行数:7,代码来源:Connection.php

示例6: checkDb

 private function checkDb()
 {
     self::_appendLog('检查数据库连接。。。');
     $dbHost = LuLu::getPostValue('dbHost');
     $dbName = LuLu::getPostValue('dbName');
     $dbUsername = LuLu::getPostValue('dbUsername');
     $dbPassword = LuLu::getPostValue('dbPassword');
     if (empty($dbHost) || empty($dbName) || empty($dbUsername)) {
         $message = '数据库信息必须填写完整';
         self::_appendLog($message, true);
         return false;
     }
     $config = ['dsn' => "mysql:host={$dbHost};dbname={$dbName}", 'username' => $dbUsername, 'password' => $dbPassword];
     $result = false;
     $message = '';
     $db = new Connection($config);
     try {
         $db->open();
         if (!$db->isActive) {
             $message = '连接失败,请检查数据库配置';
             $result = false;
         } else {
             $message = '数据库连接成功';
             $result = true;
         }
     } catch (Exception $e) {
         $db->close();
         $message = self::getDbError($e->getMessage(), ['dbHost' => $dbHost, 'dbName' => $dbName]);
         $result = false;
     }
     self::_appendLog($message, !$result);
     return $result;
 }
开发者ID:sym660,项目名称:lulucms2,代码行数:33,代码来源:SiteController.php

示例7: close

 /**
  * Closes the currently active Oracle DB connection.
  * It does nothing if the connection is already closed.
  */
 public function close()
 {
     Yii::trace('Closing Oracle connection', 'vendor\\sfedosimov\\yii2-oci8pdo\\Oci8PDO_Connection');
     parent::close();
 }
开发者ID:sfedosimov,项目名称:yii2-oci8pdo,代码行数:9,代码来源:Oci8PDO_Connection.php

示例8: actionPdf


//.........这里部分代码省略.........
            $str = '<table border=0 cellspacing=0 cellpadding=2><tbody><tr><td><img src="http://www.ubiobio.cl/mcc/images/ubbdescargagradientesolo.png"/></td><td><h1>RENDICION DE GASTOS</h1><br>Fecha: ' . date("d-m-Y") . '</td></tr></table>';
            $mpdf->WriteHTML($str);
            ///////////////////////////////////////////////////////////////////
            $sql = "Select ID_SOLICITUD, ID_TIPO_DE_VIAJE, ID_VIAJE, FECHA_SOLICITUD, CUERPO_SOLICITUD from SOLICITUD_DE_VIAJE where ID_SOLICITUD=" . $ID_SOLICITUD;
            $command = $connection->createCommand($sql);
            $dataReader = $command->query();
            $str = "<h2>- SOLICITUD:</h2><table border=1 cellspacing=0 cellpadding=2><tbody><tr><td>ID</td><td>FECHA SOLICITUD</td><td>CUERPO SOLICITUD</td></tr>";
            $dos = 1;
            foreach ($dataReader as $row) {
                $ID_TIPO_DE_VIAJE = $row->ID_TIPO_DE_VIAJE;
                $str = $str . "<tr>";
                foreach ($row as $col) {
                    if ($dos == 2) {
                        $ID_TIPO_DE_VIAJE = $col;
                    } else {
                        if ($dos == 3) {
                            $ID_VIAJE = $col;
                        } else {
                            $str = $str . "<td>" . $col . "</td>";
                        }
                    }
                    $dos = $dos + 1;
                }
                $str = $str . "</tr>";
            }
            $str = $str . "</tbody></table>";
            $mpdf->WriteHTML($str);
            ///////////////////////////////////////////////////////////////////
            $sql = "Select * from TIPO_DE_VIAJE where ID_TIPO_DE_VIAJE='" . $ID_TIPO_DE_VIAJE . "'";
            $command = $connection->createCommand($sql);
            $dataReader = $command->query();
            $str = "<h2>- TIPO DE VIAJE DE LA SOLICITUD:</h2><table border=1 cellspacing=0 cellpadding=2><tbody><tr><td>ID</td><td>NOMBRE TIPO DE VIAJE</td><td>MONTO TIPO DE VIAJE</td></tr>";
            foreach ($dataReader as $row) {
                $str = $str . "<tr>";
                foreach ($row as $col) {
                    $str = $str . "<td>" . $col . "</td>";
                }
                $str = $str . "</tr>";
            }
            $str = $str . "</tbody></table>";
            $mpdf->WriteHTML($str);
            ///////////////////////////////////////////////////////////////////
            $sql = "Select * from VIAJE where ID_VIAJE='" . $ID_VIAJE . "'";
            $command = $connection->createCommand($sql);
            $dataReader = $command->query();
            $str = "<h2>- VIAJE DE LA SOLICITUD:</h2><table border=1 cellspacing=0 cellpadding=2><tbody><tr><td>ID</td><td>ORIGEN</td><td>FECHA INICIO</td><td>FECHA TERMINO</td></tr>";
            foreach ($dataReader as $row) {
                $str = $str . "<tr>";
                foreach ($row as $col) {
                    $str = $str . "<td>" . $col . "</td>";
                }
                $str = $str . "</tr>";
            }
            $str = $str . "</tbody></table>";
            $mpdf->WriteHTML($str);
            ///////////////////////////////////////////////////////////////////
            $sql = "Select ID_DESTINO, DURACION_VIAJE_DIAS, MEDIO_DE_TRANSPORTE, CIUDAD_DESTINO, PAIS_DESTINO from DESTINO where ID_VIAJE='" . $ID_VIAJE . "'";
            $command = $connection->createCommand($sql);
            $dataReader = $command->query();
            $str = "<h2>- DESTINO(S) DEL VIAJE:</h2><table border=1 cellspacing=0 cellpadding=2><tbody><tr><td>ID</td><td>DURACION</td><td>MEDIO DE TRANSPORTE</td><td>CIUDAD DESTINO</td><td>PAIS DESTINO</td></tr>";
            foreach ($dataReader as $row) {
                $str = $str . "<tr>";
                foreach ($row as $col) {
                    $str = $str . "<td>" . $col . "</td>";
                }
                $str = $str . "</tr>";
            }
            $str = $str . "</tbody></table>";
            $mpdf->WriteHTML($str);
            ///////////////////////////////////////////////////////////////////
            $sql = "Select ID_GASTO, NOMBRE_GASTO, MONTO_GASTO, FECHA_GASTO from GASTOS where ID_VIAJE='" . $ID_VIAJE . "'";
            $command = $connection->createCommand($sql);
            $dataReader = $command->query();
            $str = "<h2>- GASTO(s) ASOCIADOS AL VIAJE:</h2><table border=1 cellspacing=0 cellpadding=2><tbody><tr><td>ID</td><td>NOMBRE</td><td>MONTO</td><td>FECHA</td></tr>";
            $id_gasto = 1;
            foreach ($dataReader as $row) {
                $str = $str . "<tr>";
                foreach ($row as $col) {
                    if ($id_gasto == 1) {
                        $ID_GASTO = $col;
                    }
                    $id_gasto++;
                    $str = $str . "<td>" . $col . "</td>";
                }
                $str = $str . "</tr>";
            }
            $str = $str . "</tbody></table>";
            $mpdf->WriteHTML($str);
            ///////////////////////////////////////////////////////////////////
            $str = '<h2>- IMAGEN(ES) ASOCIADAS A CADA GASTO:</h2><p><img src="http://www.teacherclaudio.cl/wp-content/uploads/2014/07/Boleta_01.png"/></p>
<p><img src="http://am-sur.com/am-sur/peru/selva-m/Oxapampa-notizen-d/003-busbillet-Lobato-9-okt-2008.gif"/></p>
<p><img src="http://www.cosale.cl/wp-content/uploads/2013/10/boleta.jpg"/></p>
<p><img src="https://www.reclamos.cl/files/boleta_1_0.jpg"/></p>';
            $mpdf->WriteHTML($str);
            ///////////////////////////////////////////////////////////////////
            $mpdf->Output();
            $connection->close();
            exit;
        }
    }
开发者ID:MvegaR,项目名称:ingSotfware,代码行数:101,代码来源:SiteController.php


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