I have two tables with c.id = p.category_id. I have to get categories. The name but it gives an error Would someone tell me how to get data from a composite table?
function getGalleryone () {$ data = array (); $ Query = 'SELECT * as PJ categories in products as C.id = p.category_id on ASC where c.name = "galleri1" and p.status = "active"'; $ Q = $ this- & gt; Db- & gt; Query ($ query); / * $ This- & gt; Db- & gt; Choose ('*'); $ This- & gt; Db- & gt; Where ('categories.name', 'Galleri 1'); $ This- & gt; Db- & gt; Where ('products.status', 'active'); $ This- & gt; Db- & gt; Join ('categories', 'categories.id = products.category_id'); $ This- & gt; Db- & gt; Order_by ('name', 'random'); $ Q = $ this- & gt; Db- & gt; Get ('product'); * / If ($ Q-> num_rows ()> 0) {foreach ($ Q-> result_array (as $ line) {$ data = array ("id" = & gt; $ row ['Id'], "name" = & gt; $ row ['name'], "shortdesc" = & gt; $ row ['shortdesc'], ... ... "category" => $ Row ['categories']);}} $ Q- & gt; Free_Ralt (); $ data return;
database product
If the 'product' (`id 'int (11) faucet autanarimant,` name' varchar (255) tap faucet, `short disk 'varchar (255) not faucet, not langdishi text, thumbnail varchar (255) tap, `Image 'varchar (255) tap,` class' varchar (255) default faucet, `classification' code (16) The default is' status' nm ('active', 'inactive'), `range_ID` is not an integer (11) no, zero, 'attributes' nm (' true ',' wrong ') zero,` price' float (4,2) null, primary key (`id`)) engine = mice default charge = latin1 aUTO_INCREMENT = 20;
database categories
If not, then 'Categories' (`id 'int (11) faucet autn cccment,' name 'varchar (255) not faucet,' short disk 'varchar (255) not faucet,` long dcc' text is not `Stets` Anam ( 'active', 'passive') No, amethyst,` Parentidet` ET (11) NULL, primary ( `Aidi`)) engine = Maisam default charge = latin1 AUTO_INCREMENT = 15; ... ...
error message
encountered a PHP error Severity: Information Message: Undefined Index: categories.name File Name: Model / mproducts.php Line Number: 111
Thanks in advance.
You have "name" with the name "column" by using * in * selected column * Specify in (this will improve performance in any case) such as
c.name as categories_name
No comments:
Post a Comment