SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
-
Nov 4, 2009, 04:21 #1
- Join Date
- Mar 2005
- Posts
- 319
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PDO using multiple values in one query
Code PHP:$parents = $db->prepare(" SELECT c.*, sc.is_visible, sc.id as sc_id FROM category c JOIN site_category sc ON (c.category_id = sc.category_id AND sc.site_id = :site_id) WHERE sc.parent_id = :parent_id AND sc.site_id = :site_id $categoryId $isVisible ORDER BY sc.position "); $parents->bindValue('site_id', $siteId); $parents->bindValue('parent_id', $parentId); $parents->execute(); $items = $parents->fetchAll(PDO::FETCH_OBJ);
:site_id is used twice in the query. On Windows XP local using PHP 5.3.0 this query works. On a Mac Or Linux server this query spits out an error.
My Question: Is this OS dependant or is it due to a setting in PHP / MYSQL.
(note sure what forum this goes in, so I've put it in both PHP and MYSQL.
-
Nov 4, 2009, 04:22 #2
- Join Date
- Mar 2005
- Posts
- 319
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PDO using multiple values in one query
Code PHP:$parents = $db->prepare(" SELECT c.*, sc.is_visible, sc.id as sc_id FROM category c JOIN site_category sc ON (c.category_id = sc.category_id AND sc.site_id = :site_id) WHERE sc.parent_id = :parent_id AND sc.site_id = :site_id $categoryId $isVisible ORDER BY sc.position "); $parents->bindValue('site_id', $siteId); $parents->bindValue('parent_id', $parentId); $parents->execute(); $items = $parents->fetchAll(PDO::FETCH_OBJ);
:site_id is used twice in the query. On Windows XP local using PHP 5.3.0 this query works. On a Mac Or Linux server this query spits out an error.
My Question: Is this OS dependant or is it due to a setting in PHP / MYSQL.
(note sure what forum this goes in, so I've put it in both PHP and Mysql.
-
Nov 4, 2009, 05:51 #3
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
i'm guessing this isn't a mysql problem, even if it's a mysql error message (which you didn't specify)
-
Nov 4, 2009, 06:49 #4
- Join Date
- Jun 2006
- Location
- Wigan, Lancashire. UK
- Posts
- 523
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Nov 4, 2009, 08:35 #5
- Join Date
- Oct 2006
- Location
- France, deep rural.
- Posts
- 6,869
- Mentioned
- 17 Post(s)
- Tagged
- 1 Thread(s)
This should get the err info, ftw.
PHP Code:var_dump( $items->errorInfo() );
-
Nov 4, 2009, 10:10 #6
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The manual sais you cannot use the same placeholder name multiple times.
-
Nov 4, 2009, 20:24 #7
- Join Date
- Oct 2008
- Location
- Melbourne
- Posts
- 754
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Let's keep this in one thread, thanks.
"I'm Commander Shepard, and this is
my favourite post on the internet."
We'll miss you, Dan Schulz.
Bookmarks