PHP CLASS DB QUERY

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
poyor7
Forum Newbie
Posts: 6
Joined: Tue May 23, 2006 8:38 pm

PHP CLASS DB QUERY

Post by poyor7 »

Hi....

I've problem on how to use JOIN query in PHP class...currently my coding is querying one table....so my question is what should i add in my existing code..i mean i this particular line:

Code: Select all

$this->strQuery = " Select action, ldesc, ctime , ip FROM " . $this->member_table ."" ;
The Database:
var $member_table = "member_log";
var $member_info_table = "member_info";

Code: Select all

function search_Log_Query()  {

 $use_where_stmt = false;
$this->strQuery = " Select action, ldesc, ctime , ip FROM " . $this->member_table ."" ;

if (strlen($this->l_desc) != 0){  	
    	if ($use_where_stmt) {
    	    $this->strQuery .= " and ";
    	} else {
    	    $this->strQuery .= " WHERE " ;		
    	    $use_where_stmt = true ;
    	}   	    
  	$this->strQuery .=  " ldesc like '%" . $this->l_desc . "%'";   
  	$use_where_stmt = true ;  	
    }  

}
Regards
Poyor7
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: PHP CLASS DB QUERY

Post by timvw »

[quote="poyor7"
I've problem on how to use JOIN query in PHP class[/Quote]

Why do you want to perform a join in the first place?

Which data do you need? And how are the two tables related to each other?

The most basic stuff about joins is explained in most tutorials, here's the first one i encountered when i searched the web for 'sql join': http://www.w3schools.com/sql/sql_join.asp.
Post Reply