use mysqli to get rows from a view

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cmb58
Forum Newbie
Posts: 1
Joined: Thu Oct 13, 2005 3:55 pm

use mysqli to get rows from a view

Post by cmb58 »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I have a problem to fetch values from a view.  The view is simple joint of 3 tables. Something like

Code: Select all

CREATE VIEW AList AS
SELECT	a.Name, b.Index, c.Value
FROM	TblA a, TblB b, TblC c
WHERE	a.No = b.ANo AND b.No=c.BNo

My code is very simple. It goes like this:

Code: Select all

$query = 'SELECT * FROM Alist WHERE Index=10';
$conn = new mysqli('localhost', 'User', 'password', 'database');  // this is OK
$result = $conn->query($query); // this fails
If query is the SELECT statement used in the view then this works.
My query executed from MySQL works fine.


I was wondering someone knows a workaround or maybe I am missing something here.?


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

'index' is a mysql keyword
Post Reply