Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-10-2006, 04:21 PM   #1
Registered: Jun 2005
Posts: 70

Rep: Reputation: 15
php function->query(variable) what's that?

I can understand basic php and some php-mysql, but there is something I bumped into when reading some e-commerce scripts.
$rs = $objDB->query($sql);

PHP Code:
function SetProducts($tbl,$ProductTitle,$Price...)
$sql "Insert into $tbl(ProductTitle,Price...)";
$rs $objDB->query($sql);
What does '->query($sql)' do?

Last edited by osio; 06-10-2006 at 04:30 PM.
Old 06-10-2006, 04:50 PM   #2
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
The "->" notation is used for classes. I'm not very good at it, but I think the syntax is "class->object_or_function_in_class". In your example objDB is the class and query is a function in that class. Have a look at for more info.
Old 06-10-2006, 08:38 PM   #3
LQ Newbie
Registered: Jun 2006
Posts: 21

Rep: Reputation: 15
$connectionObj->query() is...

Bebo is correct. It is a function of the pear db class. Your sql query is stored in the variable $sql. By itself, it does nothing. The pear db class is a means or a vehicle to access your database and tables. The "->query($sql) simply is a method (functions in classes are referred to as methods) that sends and executes your query on your database/table(s).

See more at:


PEAR DB provides several methods for querying databases. The most direct method is query(). It takes a SQL query string as an argument. There are three possible returns: a new DB_result object for queries that return results (such as SELECT queries), DB_OK for queries that manipulate data (such as INSERT queries) or a DB_Error object on failure.
Old 06-12-2006, 06:48 AM   #4
Registered: Jun 2005
Posts: 70

Original Poster
Rep: Reputation: 15
pear query() method

Thanks a lot Bebo and YankeeFan


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Variable = function? wh33t Programming 2 01-22-2005 06:28 AM
php mysql variable arguments in query. ldp Linux - Software 0 10-26-2004 07:56 AM
Passing one php function result as a parameter to another php function davee Programming 13 09-12-2004 12:08 PM
How to pass mysql query to a variable? chynna_v Programming 4 09-03-2004 05:09 AM
Query about script variable phantomdude Linux - Newbie 1 03-18-2004 11:21 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:46 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration