Page 1 of 1

use mysqli to get rows from a view

Posted: Thu Oct 13, 2005 4:13 pm
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]

Posted: Thu Oct 13, 2005 8:33 pm
by feyd
'index' is a mysql keyword