nor

package
v0.0.0-...-4a20ed2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2014 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugBits = 0

调试位标志, 有高位到低位分别表示 有待确定,阻断执行相关数据,怀疑参数问题,重要步骤,一般信息

View Source
var EOF = errors.New("End of Rows")

Functions

This section is empty.

Types

type Curd

type Curd struct {
	Db *sql.DB
	// contains filtered or unexported fields
}

RESTful ServeHTTP 结构

func (*Curd) Close

func (p *Curd) Close() (err error)

func (*Curd) Closed

func (p *Curd) Closed() bool

func (*Curd) Delete

func (p *Curd) Delete(query string, args ...interface{}) (ret sql.Result)

func (*Curd) Err

func (p *Curd) Err() (err error)

func (*Curd) Exec

func (p *Curd) Exec(args ...interface{}) (ret sql.Result)

func (*Curd) Get

func (p *Curd) Get(query string, args ...interface{}) (ret Rowser)

func (*Curd) Post

func (p *Curd) Post(query string, args ...interface{}) (ret sql.Result)

func (*Curd) Prepare

func (p *Curd) Prepare(query string) (err error)

func (*Curd) Put

func (p *Curd) Put(query string, args ...interface{}) (ret sql.Result)

type Curder

type Curder interface {
	Err() error
	Close() error
	Closed() bool
	Get(query string, args ...interface{}) Rowser
	Post(query string, args ...interface{}) sql.Result
	Put(query string, args ...interface{}) sql.Result
	Delete(query string, args ...interface{}) sql.Result
	Prepare(query string) error
	Exec(args ...interface{}) sql.Result
}

Curder 提供了一种简易方法操作数据库 Get 方法返回 Rowser,细节见 Rowser Post,Put,Delete都是单条 update 操作的情况,没有对重复SQL进行Prepare优化支持 如果要使用Prepare优化SQL请使用 Prepare,Exec

func NewCurd

func NewCurd(db *sql.DB) Curder

type DB

type DB struct{}

type DBer

type DBer interface{}

type Rows

type Rows struct {

	//列名称 map, 其 int 值从 1 开始,对 Cols 增删或者改变其绝对值会造成不可预计的错误
	//可以通过设置 Cols[key] 为负数(绝对值不能变), 来过滤 Get 返回的 map
	Cols map[string]int
	// contains filtered or unexported fields
}

func NewRows

func NewRows(rows *sql.Rows) (ret *Rows, err error)

有*sql.Rows和其相关的 struct 对象实例创建 nor.Rows 对象实例

func (*Rows) Close

func (p *Rows) Close() (err error)

手动关闭

func (*Rows) Closed

func (p *Rows) Closed() bool

func (*Rows) Dst

func (p *Rows) Dst(dst interface{}) Rowser

绑定目标 struct 对象实例 返回值:bool, true 目标对象实例被绑定, false 取消原绑定的目标对象实例

func (*Rows) Err

func (p *Rows) Err() (err error)

返回发生的错误,只遇到任何一次错误,Rows 都会拒绝后续操作并关闭

func (*Rows) Row

func (p *Rows) Row(dest ...interface{}) (ret map[string]reflect.Value)

如果只有一个参数并且是 *struct 类型,以 map[string]reflect.Value 形式返回一条记录 否则相当于调用 Rows.Scan 如果遇到错误, 返回 nil, 并自动关闭, 调用 Rows.Err() 查看错误 如果没有数据, 返回 nil, 并自动关闭, 调用 Rows.Err() 将返回 EOF

func (*Rows) Rowi

func (p *Rows) Rowi(dest ...interface{}) (ret map[string]interface{})

以 map[string]interface{} 形式返回一条记录 如果遇到错误, 返回 nil, 并自动关闭, 调用 Rows.Err() 查看错误 如果没有数据, 返回 nil, 并自动关闭, 调用 Rows.Err() 将返回 EOF

func (*Rows) Scan

func (p *Rows) Scan(dest ...interface{}) error

支持 struct 对象实例作为参数,如果这样用,该 struct 对象实例比须是唯一的参数 如果参数违背了参数规则, 将返回错误, 此错误不影响再次 Scan 操作 如果没有数据设置 error 为 EOF, 并自动关闭

type Rowser

type Rowser interface {
	Err() error
	Close() error
	Closed() bool
	Dst(interface{}) Rowser
	Scan(...interface{}) error
	Rowi(...interface{}) map[string]interface{}
	Row(...interface{}) map[string]reflect.Value
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL