Example #1
0
<?php

iiWork::import('db.db');
class iiDBMysql extends iiDB
{
    public $init_query;
    public function connect($host = "localhost", $id, $pass, $db = '')
    {
        $this->host = $host;
        $this->id = $id;
        $this->pass = $pass;
        $this->db = $db;
        echo $this->host;
        $this->sql = mysql_connect($host, $id, $pass, $this->no != 0 ? true : false);
        if (!$this->sql) {
            throw new Exception('DB 연결에 실패했습니다 ' . mysql_error());
        }
        // 초기 쿼리
        if ($this->init_query) {
            $this->query($this->init_query);
        }
        // db 선택
        $this->select_db($db);
    }
    public function select_db($name)
    {
        if (!mysql_select_db($name, $this->sql)) {
            throw new Exception('DB 선택에 실패했습니다 ' . mysql_error());
        }
    }
    public function close()