| 包 | XS.util.db | 
|---|---|
| 继承关系 | class XSDatabasePgSQL » XSDatabase | 
| 版本 | 1.0.0 | 
| 源代码 | sdk/php/util/XSDataSource.class.php | 
| 名称 | 描述 | 定义于 | 
|---|---|---|
| close() | 关闭数据库连接 | XSDatabasePgSQL | 
| connect() | XSDatabasePgSQL | |
| query() | 执行 SQL 语句查询 | XSDatabasePgSQL | 
| query1() | 查询数据库首行 | XSDatabase | 
| setUtf8() | 将输出字符集设置为 UTF-8 | XSDatabasePgSQL | 
| 
public void close() | 
public function close()
{
    if (is_resource($this->link)) {
        pg_close($this->link);
        $this->link = null;
    }
}
关闭数据库连接
| 
public void connect($param) | ||
| $param | ||
public function connect($param)
{
    $dsn = "host={$param['host']} ";
    $dsn .= isset($param['port']) ? "port={$param['port']} " : '';
    $dsn .= "dbname={$param['dbname']} user={$param['user']} password={$param['pass']}";
    if (!($this->link = @pg_connect($dsn))) {
        throw new XSException('Error connecting to PGSQL database:' . $param['dbname'] . '.');
        pg_set_error_verbosity($this->link, PGSQL_ERRORS_DEFAULT);
        pg_query('SET standard_conforming_strings=off');
    }
}
| 
public mixed query(string $query) | ||
| $query | string | 要执行的 SQL 语句 | 
| {return} | mixed | |
public function query($query)
{
    //echo "[DEBUG] SQL: $sql\n";
    $res = pg_query($this->link, $query);
    if ($res === false) {
        throw new XSException('PgSQL ERROR: ' . pg_last_error($this->link));
    }
    $ret = array();
    while ($tmp = pg_fetch_assoc($res)) {
        $ret[] = $tmp;
    }
    pg_free_result($res);
    return $ret;
}
执行 SQL 语句查询
| 
public void setUtf8() | 
public function setUtf8()
{
    pg_set_client_encoding($this->link, 'UTF8');
}
将输出字符集设置为 UTF-8
| 包 | XS.util.db | 
|---|---|
| 继承关系 | class XSDatabasePgSQL » XSDatabase | 
| 版本 | 1.0.0 | 
| 源代码 | sdk/php/util/XSDataSource.class.php | 
| 名称 | 描述 | 定义于 | 
|---|---|---|
| close() | 关闭数据库连接 | XSDatabasePgSQL | 
| connect() | XSDatabasePgSQL | |
| query() | 执行 SQL 语句查询 | XSDatabasePgSQL | 
| query1() | 查询数据库首行 | XSDatabase | 
| setUtf8() | 将输出字符集设置为 UTF-8 | XSDatabasePgSQL | 
| 
public void close() | 
public function close()
{
    if (is_resource($this->link)) {
        pg_close($this->link);
        $this->link = null;
    }
}
关闭数据库连接
| 
public void connect($param) | ||
| $param | ||
public function connect($param)
{
    $dsn = "host={$param['host']} ";
    $dsn .= isset($param['port']) ? "port={$param['port']} " : '';
    $dsn .= "dbname={$param['dbname']} user={$param['user']} password={$param['pass']}";
    if (!($this->link = @pg_connect($dsn))) {
        throw new XSException('Error connecting to PGSQL database:' . $param['dbname'] . '.');
        pg_set_error_verbosity($this->link, PGSQL_ERRORS_DEFAULT);
        pg_query('SET standard_conforming_strings=off');
    }
}
| 
public mixed query(string $query) | ||
| $query | string | 要执行的 SQL 语句 | 
| {return} | mixed | |
public function query($query)
{
    //echo "[DEBUG] SQL: $sql\n";
    $res = pg_query($this->link, $query);
    if ($res === false) {
        throw new XSException('PgSQL ERROR: ' . pg_last_error($this->link));
    }
    $ret = array();
    while ($tmp = pg_fetch_assoc($res)) {
        $ret[] = $tmp;
    }
    pg_free_result($res);
    return $ret;
}
执行 SQL 语句查询
| 
public void setUtf8() | 
public function setUtf8()
{
    pg_set_client_encoding($this->link, 'UTF8');
}
将输出字符集设置为 UTF-8
留下一条评论吧!
请到论坛 登录 后刷新本页面!