Comments (5)
Hi golgote, you can retrieve column names from a select by passing true as a
parameter to the 'fetch' or 'rows' method of a statement handle. By default
'fetch'
or 'rows' returns a numerically index table (AKA an array), but by passing true
to
these methods the result is return as a table indexed by column names.
See the examples on http://code.google.com/p/luadbi/wiki/DBDDriverStatement for
more
details.
Original comment by [email protected]
on 5 Apr 2009 at 5:14
from luadbi.
Yes, I noticed that, but columns in the table can be in any order (since that's
the way tables work in Lua). To
build specific functions like "getAssoc" (and some others for my ORM), I need
to know in which order the
columns were fetched, that's why a function to get the column names is useful.
Thanks for your reply :)
Original comment by [email protected]
on 6 Apr 2009 at 10:26
from luadbi.
I've had a look at the source code, and the functionality should be relatively
easy
to add. The implementation will look something like:
local sth = dbh:prepare('SELECT id,num,timestamp FROM sometable')
sth:execute()
-- fields will be equal to {'id','num','timestamp'}
local fields = sth:columns()
I'll look at adding this in the next week.
Original comment by [email protected]
on 9 Apr 2009 at 12:48
from luadbi.
I've committed changes to implement the 'columns' method for statement handles
into
SVN. I'll be uploading a new release source package shortly.
Original comment by [email protected]
on 17 Apr 2009 at 11:49
- Changed state: Fixed
from luadbi.
Thank you Neil :)
Original comment by [email protected]
on 19 Apr 2009 at 8:45
from luadbi.
Related Issues (20)
- Add ODBC driver HOT 2
- How execute prepared query multiple times. HOT 3
- Segfault in SQLite3 driver HOT 3
- Add tag(s) with version numbers HOT 8
- missing locks on SQLite3 DB file and WAL shm file HOT 3
- Segfault dbdpostgresql.so HOT 2
- Support SSL connection options HOT 2
- Make a new release (0.7) HOT 8
- DB2 Bug HOT 1
- Postgres backend leaks prepared statements HOT 4
- Release 0.7.2 HOT 4
- Automate LuaRocks
- Invalid pointer being assigned to struct
- Wrong oracle column names HOT 1
- PostgreSQL: Notice processing
- MySQL 8: Error executing statement parameters: Incorrect arguments to mysqld_stmt_execute HOT 17
- Compilation error in FreeBSD HOT 1
- Cannot differentiate NULL and default value with MySQL HOT 1
- Backport lua5.4 support for Debian Bullseye? HOT 5
- how to build the odbc flavour HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luadbi.