PHP Classes

table join

Recommend this page to a friend!

      AJAX Paginator  >  AJAX Paginator package blog  >  Ajax Paginator 1.5  >  All threads  >  table join  >  (Un) Subscribe thread alerts  
Subject:table join
Summary:how to join two table or more
Messages:2
Author:cuma elp
Date:2009-10-28 04:18:16
Update:2009-11-06 11:39:29
 

  1. table join   Reply   Report abuse  
Picture of cuma elp cuma elp - 2009-10-28 04:18:16
this class's awesome. i've try the example and it works perfectly.
but, because i'm new to php, i haven't figured out how to join two table or more. where should i put those join query?

  2. Re: table join   Reply   Report abuse  
Picture of Omar Abdallah Omar Abdallah - 2009-11-06 11:39:29 - In reply to message 1 from cuma elp
You will put it on both pages. testpage.php and sub_page.php

but you will have to cascade the column names in the search fields($fields property on the object)

here is a sample of its implementation:

Let's say we have categories for customer a table called 'category' with fields 'category_id' and 'category_name' and you'll have to add a foreign key in the customer's table:

the query will be like that:
$query = "SELECT cust.id, cust.name, cat.category_name FROM customers AS cust
LEFT JOIN category AS cat ON (cust.category_id = cat.category_id)";

to cascade it into the search fields(columns)
you will specify the fields with the table prefix:
$paginator->fields = 'cust.name';

or if you want to enable the search for the category name also(or any multiple fields) you will make it an array of fields as the following:
$paginator->fields = array('cust.name','cat.category_name');

That's all

Thank you for your rating, and if you need anything don't hesitate to ask about it.