# SQLite API deficiency

- Thread: https://externals.io/message/9833
- Original archive: https://news-web.php.net/php.internals/9833
- Started by Stanislav Malyshev on 2004-05-13T13:25:59+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #9833 — Stanislav Malyshev — 2004-05-13T13:25:59+00:00

URL: https://externals.io/message/9833#9833

I have discovered that SQLite function sqlite_query runs sqlite_exec 
function if it's return value is used and sqlite_compile/sqlite_step combo 
if return value is used. I think this is a problem - if I want to run some 
pack of queries (like, create whole DB schema in one call), I can do it 
with sqlite_query - but only if I don't check the return value - and thus 
don't know if it succeeded or not! If I check the return value, it runs 
sqlite_compile/sqlite_step, which can not run multiple SQL statements. 

I think this should be fixed. In order not to break BC, I propose to add 
new function to SQLite API - sqlite_exec, which - surprise! - would always 
call sqlite_exec and would return only true/false. Though, the even better 
solution would be to kill that return_value_used check altogether and use 
two separate functions always, depending on the task.

Any thoughts about this?
-- 
Stanislav Malyshev, Zend Products Engineer   
stas@zend.com  http://www.zend.com/ +972-3-6139665 ext.115

---

## #9834 — Wez Furlong — 2004-05-13T13:32:44+00:00

URL: https://externals.io/message/9833#9834 · In reply to: #9833

I've been bitten by this too, but didn't get time to delve into it.

Can the compile/step definitely not handle multiple queries?
That's a shame :/

I'm currently in DB API mode (working on PDO), so I'll refresh my memory
and do some sqlite stuff over the next few days; if there is no way to
get the compile/step executing multiple queries, then we will need a new
function as you suggest.

--Wez.

> -----Original Message-----
> From: Stanislav Malyshev [mailto:stas@zend.com] 
> Sent: 13 May 2004 14:26
> To: PHP Development
> Subject: [PHP-DEV] SQLite API deficiency
> 
> I have discovered that SQLite function sqlite_query runs sqlite_exec 
> function if it's return value is used and 
> sqlite_compile/sqlite_step combo 
> if return value is used. I think this is a problem - if I 
> want to run some 
> pack of queries (like, create whole DB schema in one call), I 
> can do it 
> with sqlite_query - but only if I don't check the return 
> value - and thus 
> don't know if it succeeded or not! If I check the return 
> value, it runs 
> sqlite_compile/sqlite_step, which can not run multiple SQL 
> statements. 
> 
> I think this should be fixed. In order not to break BC, I 
> propose to add 
> new function to SQLite API - sqlite_exec, which - surprise! - 
> would always 
> call sqlite_exec and would return only true/false. Though, 
> the even better 
> solution would be to kill that return_value_used check 
> altogether and use 
> two separate functions always, depending on the task.
> 
> Any thoughts about this?
> -- 
> Stanislav Malyshev, Zend Products Engineer   
> stas@zend.com  http://www.zend.com/ +972-3-6139665 ext.115

---

## #9835 — Ilia Alshanetsky — 2004-05-13T13:46:05+00:00

URL: https://externals.io/message/9833#9835 · In reply to: #9833

> I have discovered that SQLite function sqlite_query runs sqlite_exec
> function if it's return value is used and sqlite_compile/sqlite_step combo
> if return value is used. I think this is a problem - if I want to run some
> pack of queries (like, create whole DB schema in one call), I can do it
> with sqlite_query - but only if I don't check the return value - and thus
> don't know if it succeeded or not! If I check the return value, it runs
> sqlite_compile/sqlite_step, which can not run multiple SQL statements.

You could always check the status of the query by running the 
sqlite_last_error().

> I think this should be fixed. In order not to break BC, I propose to add
> new function to SQLite API - sqlite_exec, which - surprise! - would always
> call sqlite_exec and would return only true/false.

Good idea.

> Though, the even better 
> solution would be to kill that return_value_used check altogether and use
> two separate functions always, depending on the task.

I'd prefer to have sqlite_exec() like you propose and leave sqlite_query() as 
is.

Ilia
