Ad

OctoberCMS | Db Class For Multi-argument Query

- 1 answer

I'm trying to fire a simple multi-arg query using the static class Db, but I get an error:

SQLSTATE[HY093]: Invalid parameter number (SQL: select idy, keywords  FROM jb_tal_detail WHERE tid = 1 AND idy= ?)

This is my query, where both variables exist:

Db::select('select  idy, keywords  FROM  jb_tal_detail WHERE tid = ? AND idy= ?', [$uid], [$idy] );    

From the error msg looks like $idy is not defined ($idy=1), or the 2nd argument is not allowed (really?).

Can anyone suggest what am I doing wrong? Thanks

Ad

Answer

try this.

Db::select('select  idy, keywords  FROM  jb_tal_detail WHERE tid = ? AND idy= ?', [$uid, $idy] );
Ad
source: stackoverflow.com
Ad