/    Sign up×
Community /Pin to ProfileBookmark

understanding a "Query" that came from no where .

Hey guts check out this script ?? :

[CODE]<?php
ini_set(“display_errors”,”1″);
ERROR_REPORTING(E_ALL);

include_once(‘universal_connect.php’);
class CreateTable
{
private $tableMaster;
private $hookup;
private $sql;

public function __construct()
{
$this->tableMaster=”gautam”;
$this->hookup=UniversalConnect::doConnect();

$drop = “DROP TABLE IF EXISTS $this->tableMaster”;

[COLOR=”#FF0000″]if($this->hookup->query($drop) === true)[/COLOR]
{
printf(“Old table %s has been dropped.<br/>”,$this->tableMaster);
}

$this->sql = “CREATE TABLE $this->tableMaster (
id SERIAL,
name NVARCHAR(30),
email NVARCHAR(36),
lang NVARCHAR(10),
PRIMARY KEY(id)
)”;

if($this->hookup->query($this->sql) === true)
{
printf(“Table $this->tableMaster has been created successfully.<br/>”);
}

$this->hookup->close();
}
}

$worker=new CreateTable();

?>[/CODE]

check out the part highlighted in red , now i really don’t understand what that “query” is doing ? i checked all of the external files associated with this script and none had a method called query ?? is it an inbuilt query in PHP ?? if so i could’t find it in the docs . (maybe because i donno what object this method is associated with . ).

I would really appreciate any help .

Thank you.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@iBeZiDec 22.2014 — It looks like the "query" method belongs to the object instance returned by the "doConnect" method of the "UniversalConnect" class
Copy linkTweet thisAlerts:
@gautamz07authorDec 22.2014 — The object returned by UniversalConnect is :

[CODE]self::$hookup=mysqli_connect(self::$server, self::$user, self::$pass, self::$currentDB);[/CODE]

can u now tell me what that query method came from ?? or point me to some relevant documentation.

Thanks .

Gautam.
Copy linkTweet thisAlerts:
@iBeZiDec 22.2014 — The query method belongs to the mysqli object returned by the mysql_connect function, look up mysqli
Copy linkTweet thisAlerts:
@gautamz07authorDec 22.2014 — mysqli is a pritty broad topic ! wht shld i look up for "methods of mysqli" ???? can u like gimme a phrase i can type in google .
Copy linkTweet thisAlerts:
@NogDogDec 22.2014 — Go to http://php.net/mysqli and search for "mysqli::query"
×

Success!

Help @gautamz07 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...