Skip to content

Instantly share code, notes, and snippets.

@marsnow
Last active June 21, 2016 09:55
Show Gist options
  • Select an option

  • Save marsnow/a8610533c258eb96fa50bf3351cefa25 to your computer and use it in GitHub Desktop.

Select an option

Save marsnow/a8610533c258eb96fa50bf3351cefa25 to your computer and use it in GitHub Desktop.
<?php
class Database
{
private $servername;
private $username;
private $password;
private $dbname;
private $conn;
private function connectDB()
{
for ($i = 0; $i < 3;++$i) {
sleep(rand(1, 10) * $i);
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_errno) {
errLog('MySQL 連線失敗第 '.($i + 1)." 次:: (錯誤代碼: $conn->connect_errno) $conn->connect_error");
}
}
return $conn;
}
public function setMysqli($servername, $username, $password, $dbname)
{
$this->servername = $servername;
$this->username = $username;
$this->password = $password;
$this->dbName = $dbname;
}
public function getConnection()
{
return $this->connectDB();
}
}
class PhotoQuery
{
private $photoSource;
private $minx;
private $miny;
private $maxx;
private $maxy;
private function getPhotos()
{
}
public function setPhotoSource($source)
{
}
public function setCoordinate($minx, $miny, $maxx, $maxy)
{
$this->minx = $minx;
}
}
class Log
{
private $location;
public $messages;
private function saveLog()
{
}
public function setLog($message)
{
}
}
Database->setMysqli('localhost', 'root','0000','larvata_travel');
PhotoQuery->setPhotoSource('panoramio');
PhotoQuery->setCoordinate('120','20','122','25');
PhotoQuery->save();
Database->close();
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment