mysql - php relationship key error -
I have several tables in mysql that are related to a relationship. Each has their own unique ID and data. Only when they try to query them I get a strange result:
(use print_r) array ([0] => Array ([id] = & gt; ; 1 [0] = & gt; 1 [Tbl2_id] => 1 [1] => 1 [tbl3_id] => 1 [2] => 1 [3] = & gt; 1 [Name] = & gt; name 1 [4] = & gt; name 1 [surname] = & gt; ...)
I should not do that.
For example, it should look like this:
[pre] (use print_r) array ([0] => array ([ID] => 1 [ Tbl1_id] => 1 [tbl2_id] = & gt; 1 [tbl2_tbl1id] => 1 [Tbl3_id] => 1 [tbl2_tbl1id] => 1 ...))
or something like this I like the PDO and when I invoke SQL, something looks like this:
SELECT FROM `tbl` Join INNER (tbl2, tbll) tbl on Tbl1_id = tbl1.id and tbl.tbl2_id = tbl2 .id WHERE 1
After using it in mysql, there is such an effect in the picture (run SQL query / database Question)
It seems that you can fetch_style pdostattement :: With PDO :: FETCH_BOTH are used - which is the default.
Use PDO :: FETCH_ASSOC as fetch_style, and you should get what you want.
$ result = $ sth- & gt; Bringing (PDO :: FETCH_ASSOC); Print_r ($ result);
Comments
Post a Comment