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


PHP CDatabase::connect方法代码示例

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


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

示例1: CDatabase

<?php

include "../../librerias/CDatabase.php";
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
$oDB = new CDatabase();
switch ($_REQUEST['action']) {
    case 'obtener-personas':
        $sSQL = "\n            SELECT  \n                personas.per_id, \n                personas.per_dni, \n                personas.per_nombre, \n                personas.per_apellido\n            \n            FROM \n                personas \n            \n            ORDER BY \n                personas.per_dni\n            ;\n        ";
        //  Creo una conexión.
        $oDB->connect();
        // Ejecutar la consulta SQL.
        $oDB->query($sSQL);
        // Desconectarse de la base de datos.
        $oDB->disconnect();
        // Guardar resultado de la consulta SQL en un arreglo.
        $arr = $oDB->resultToArray();
        // Convierte un string a formato JSON.
        print json_encode($arr);
        break;
    case 'agregar-donacion':
        $donacion = json_decode(file_get_contents("php://input"));
        //echo "$donacion->nombre";
        $valores = "(" . "'" . $donacion->don_fecha . "', " . $donacion->per_id . ")";
        $sSQL = "\n            INSERT INTO donaciones (\n                don_fecha, \n                don_persona) \n            \n            VALUES " . $valores . ";";
        /*
        $stringPrueba = "abc";
        echo ("String: " . $sSQL);
        */
        // Creo una conexión.
        $oDB->connect();
        // Ejecuto la consulta.
开发者ID:robysottini,项目名称:donaciones,代码行数:31,代码来源:formulario-donacion.php

示例2: CDatabase

<?php

//инициализируем класс БД
require PATH_CORE . 'database/database.php';
$oDb = new CDatabase('mysql', 'mysql:host=' . DB_HOST_SYSGEN . ';dbname=' . DB_NAME_SYSGEN, DB_USER_SYSGEN, DB_PASS_SYSGEN);
//$oDb = new CDatabase('pgsql', 'pgsql:port=5432 dbname='.DB_NAME_SYSGEN, DB_USER_SYSGEN, DB_PASS_SYSGEN);
$oDb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$oDb->connect();
//инициализируем Config
config::load();
$oConfig =& config::$data;
if (BFF_DEBUG || FORDEV) {
    include PATH_CORE . 'vardump.php';
    $oDb->bShowStatistic = true;
    $oDb->bMakeStatistic = true;
}
//инициализируем Smarty
require PATH_CORE . 'external/smarty/smarty.class.php';
$oSm = new Smarty();
$oSm->force_compile = false;
$oSm->compile_check = true;
$oSm->debugging = false;
$oSm->compile_dir = PATH_BASE . 'tpl_c';
$oSm->config_dir = PATH_BASE . 'config';
$oSm->plugins_dir = array('plugins', 'plugins/bff');
Module::adminCustomCenterArea(false);
$oSm->assign('fordev', FORDEV);
$oSm->assign('site_url', SITEURL);
$oSm->assign_by_ref('config', $oConfig);
开发者ID:Sywooch,项目名称:dobox,代码行数:29,代码来源:init.php

示例3: connect

        $this->password = '123';
        $this->dbname = 'test';
    }
    public function connect()
    {
        echo "Connect to db";
        echo "<pre>";
        print_r($this->host);
        print_r($this->user);
        print_r($this->password);
        print_r($this->dbname);
        echo "</pre>";
    }
}
$db = new CDatabase();
$db->connect();
class CHumen
{
    public static $eyes = 2;
    public static $hands = 2;
    private static $religion = "xxx";
    private $name;
    private $age;
    private $db;
    public function __construct($name = '', $age = 0)
    {
        $this->name = $name;
        $this->age = $age;
        $this->db = new CDatabase();
    }
    public function setName($name)
开发者ID:AleksandrAstapov,项目名称:Source_IT,代码行数:31,代码来源:si_lesson_10_1.php


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