Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are some SQLite functions zero-based and some one-based

The index parameter for sqlite3_column_* is zero-based while sqlite3_bind_* is one-based.

Is there a reason for this?

like image 414
dalle Avatar asked Oct 07 '11 09:10

dalle


1 Answers

I've got it.

Blame sqlite3_bind_parameter_index:

Return the index of an SQL parameter given its name. The index value returned is suitable for use as the second parameter to sqlite3_bind(). A zero is returned if no matching parameter is found.

So there you go. Odd choice, considering they seem to be using a signed int for the index, meaning they could have used -1 to indicate a no-match. Maybe the reason behind that is more historical, SQLite has been around for a while...

like image 114
MPelletier Avatar answered Nov 08 '22 21:11

MPelletier