|
@@ -99,6 +99,7 @@ func (d *DB) Connect() (err error) {
|
|
|
|
|
|
// Close close database connect
|
|
// Close close database connect
|
|
func (d *DB) Close() {
|
|
func (d *DB) Close() {
|
|
|
|
+ // use pool
|
|
//d.conn.Close()
|
|
//d.conn.Close()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -147,6 +148,19 @@ func (d *DB) TransUpdate(query string, args interface{}) (reply Reply) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Select select
|
|
|
|
+func (d *DB) Select(dest interface{}, query string, args ...interface{}) error {
|
|
|
|
+ err := d.Connect()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ defer d.Close()
|
|
|
|
+
|
|
|
|
+ err = d.conn.Select(dest, query, args...)
|
|
|
|
+
|
|
|
|
+ return err
|
|
|
|
+}
|
|
|
|
+
|
|
// Rows get rows
|
|
// Rows get rows
|
|
func (d *DB) Rows(dest interface{}, query string, args interface{}) error {
|
|
func (d *DB) Rows(dest interface{}, query string, args interface{}) error {
|
|
err := d.Connect()
|
|
err := d.Connect()
|
|
@@ -166,6 +180,19 @@ func (d *DB) Rows(dest interface{}, query string, args interface{}) error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Get get
|
|
|
|
+func (d *DB) Get(dest interface{}, query string, args ...interface{}) error {
|
|
|
|
+ err := d.Connect()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+ defer d.Close()
|
|
|
|
+
|
|
|
|
+ err = d.conn.Get(dest, query, args...)
|
|
|
|
+
|
|
|
|
+ return err
|
|
|
|
+}
|
|
|
|
+
|
|
// Row get row
|
|
// Row get row
|
|
func (d *DB) Row(dest interface{}, query string, args interface{}) error {
|
|
func (d *DB) Row(dest interface{}, query string, args interface{}) error {
|
|
err := d.Connect()
|
|
err := d.Connect()
|