Wrong SQL patterns in amazon_item_lookup_from_db
I get this error
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: SELECT * from {amazon_item} WHERE asin IN (:asins_0141390123, asins_B0050JKPN8, asins_B005KG60V2, asins_0873642481) AND timestamp > :timestamp; Array ( [timestamp] => 1333143603 [asins_0141390123] => 0141390123 [asins_B0050JKPN8] => B0050JKPN8 [asins_B005KG60V2] => B005KG60V2 [asins_0873642481] => 0873642481 ) in amazon_item_lookup_from_db() (line 474 of /var/www/d7/drupal-7.12/sites/all/modules/amazon/amazon.module).
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | fixed_malformed_query_placeholders-1510816-16.patch | 1.15 KB | willvincent |
| #12 | amazon-1510816-wrong_sql_params-1.patch | 1.02 KB | Anonymous (not verified) |
| #11 | amazon-1510816-wrong_sql_params.patch | 635 bytes | Anonymous (not verified) |
| #9 | Screenshot at 2012-04-11 18:18:33.png | 74.21 KB | Anonymous (not verified) |
| #7 | amazon - viktor.zip | 91.56 KB | PGreenwald |
Comments
Comment #1
Anonymous (not verified) commentedThe wrong sql patterns used.
Need to be like
amazon.module, line 472
$result = db_query('SELECT * from {amazon_item} WHERE asin IN (:asins) AND timestamp > :timestamp',
array(':asins' => $item_ids, ':timestamp' => $timestamp),
array(':fetch' => PDO::FETCH_ASSOC));
Comment #2
rfayPlease explain exactly what action you took to get this error. Are you using mysql? What ASIN were you querying?
Of course it seems odd that this is the first report of this unless there's something unusual about your installation.
Is it possible you haven't run update.php, or that your database is somehow damaged?
Comment #3
Anonymous (not verified) commentedI wanted to say that. There is not used the Drupal 7 database posibilities. Yes, It works like in Drupal 6.
But you pass parameters in to query in a wrong way. Keys of parameters should be the same as in the query.
So we shoud use ":" like array(':asins' => .
There is a like "array('asins' => " It is wrong.
Comment #4
rfayAgain, Please explain exactly what action you took to get this error. Are you using mysql? What ASIN were you querying?
Comment #5
Anonymous (not verified) commentedI hae ported the module amazon_import to D7.
http://drupal.org/node/1437028#comment-5811614
It does not want to work until, I have not fixed it.
amazon_lookup .
Comment #6
rfayWell, an actual patch is welcome, but it does seem like this might be an error in your module.
Comment #7
PGreenwald commentedViktor made the module for me. Do you think the module can be changed to work with the amazon module? Right now it only works with the attached version of the amazon module and it gives several notices. It also does not work well with the Amazon Store module.
Thanks for your help.
Comment #8
rfay#7: We won't support random forks of Amazon module, sorry.
Comment #9
Anonymous (not verified) commentedHello.
I try to work as Drupal professional.
Please, correct me if I am wrong.
-----------------------------------------------------
In my own code I use this.
And I receive this.
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens: SELECT * from {amazon_item} WHERE asin IN (:asins_1590207238, asins_B0007XLNWY) AND timestamp > :timestamp; Array ( [timestamp] => 1334070552 [asins_1590207238] => 1590207238 [asins_B0007XLNWY] => B0007XLNWY ) in amazon_item_lookup_from_db() (line 474 of /var/www/d7/drupal-7.12/sites/all/modules/amazon/amazon.module).Comment #10
rfayI guess the question would be what's in $asins.
Since the module would not work in any way if this didn't work... I suspect you have a problem with your code.
Comment #11
Anonymous (not verified) commentedI have attached a git patch.
This is your variant.
Make the attention on ":". It does not determine the sql parameter. We can use any pointer to(@ - for an example).
Sorry.
Comment #12
Anonymous (not verified) commentedI propose to use this construction in this part.
We work under Drupal 7, we need use the db_select.
Comment #13
rfayStatic queries with db_query() are perfectly acceptable in D7. http://drupal.org/node/310072
Comment #14
Anonymous (not verified) commentedOk, you are right.
Look over that articles, look how to use parameters right.
Try to find a difference between your code and the snippets in that article.
Comment #15
willvincent commentedCommit patch from #12 to 7.x-1.x-dev branch.
Comment #16
willvincent commentedCaught a couple more that didn't make it in before the 7.x-1.1 release. :(
Here's a patch, and this has also been commit to 7.x-1.x-dev branch.
Comment #17
willvincent commented