Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
ca2fb674
Commit
ca2fb674
authored
Apr 20, 2012
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Stmt#SelectOneRow method.
parent
30746961
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
sqlite.go
sqlite.go
+1
-0
stmt.go
stmt.go
+13
-1
No files found.
sqlite.go
View file @
ca2fb674
...
...
@@ -461,6 +461,7 @@ func (c *Conn) Close() error {
rv
:=
C
.
sqlite3_close
(
c
.
db
)
if
rv
!=
C
.
SQLITE_OK
{
Log
(
int
(
rv
),
"error while closing Conn"
)
return
c
.
error
(
rv
)
}
c
.
db
=
nil
...
...
stmt.go
View file @
ca2fb674
...
...
@@ -78,7 +78,7 @@ type Stmt struct {
params
map
[
string
]
int
// cached parameter index by name
// Enable type check in Scan methods (default true)
CheckTypeMismatch
bool
// Tell if the stmt should be cached (default
fals
e)
// Tell if the stmt should be cached (default
tru
e)
Cacheable
bool
}
...
...
@@ -205,6 +205,17 @@ func (s *Stmt) Select(rowCallbackHandler func(s *Stmt) error, args ...interface{
return
nil
}
// Args are for scanning (not binding).
// Returns false if there is no matching row.
func
(
s
*
Stmt
)
SelectOneRow
(
args
...
interface
{})
(
bool
,
error
)
{
if
ok
,
err
:=
s
.
Next
();
err
!=
nil
{
return
false
,
err
}
else
if
!
ok
{
return
false
,
nil
}
return
true
,
s
.
Scan
(
args
...
)
}
// Number of SQL parameters
// (See http://sqlite.org/c3ref/bind_parameter_count.html)
func
(
s
*
Stmt
)
BindParameterCount
()
int
{
...
...
@@ -881,6 +892,7 @@ func (s *Stmt) finalize() error {
}
rv
:=
C
.
sqlite3_finalize
(
s
.
stmt
)
if
rv
!=
C
.
SQLITE_OK
{
Log
(
int
(
rv
),
"error while finalizing Stmt"
)
return
s
.
error
(
rv
)
}
s
.
stmt
=
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment