本文整理汇总了PHP中Connection::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getInstance方法的具体用法?PHP Connection::getInstance怎么用?PHP Connection::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Method __construct
*
* Cria as configurações padrão do objeto Model
*
* @param string
*/
public function __construct($table = null)
{
if ($table !== null) {
$this->setTable($table);
}
$this->conn = Connection::getInstance();
}
示例2: signup
public static function signup()
{
$dbh = Connection::getInstance()->connect();
if (isset($_POST['email']) && !isset($_POST['username'])) {
$email = $_POST['email'];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "invalid";
} else {
$stmt = $dbh->prepare("SELECT id FROM users WHERE email=:email");
$stmt->bindParam(':email', $email);
$stmt->execute();
$stmt = $stmt->fetch();
if ($stmt) {
echo "exist";
} else {
echo "ok";
}
}
}
if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password'])) {
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$stmt = $dbh->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)");
$stmt->bindParam(':username', $username);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':password', $password);
$stmt->execute();
}
}
示例3: delete
public static function delete($id)
{
$db = Connection::getInstance();
$sql = "DELETE FROM sse_answer WHERE thread_id = :id";
$statement = $db->prepare($sql);
$statement->execute(array(':id' => $id));
}
示例4: setIsdatepassed
public static function setIsdatepassed($isdatepassed)
{
$db = Connection::getInstance();
$mysqli = $db->getConnection();
$query = "update deadline set isdatepassed='{$isdatepassed}';";
$result = $mysqli->query($query);
return $result;
}
示例5: countPosts
public function countPosts()
{
$conn = Connection::getInstance("read");
$command = "SELECT COUNT(*) AS count \n\t\t\t\t\tFROM post_to_cats \n\t\t\t\t\tWHERE cat_id = {$this->id}";
$r = $conn->execObject($command);
$row = mysqli_fetch_assoc($r);
return $row['count'];
}
示例6: refundOrder
public static function refundOrder($orderCode, $amount)
{
if (!empty($amount) && is_numeric($amount)) {
$json = json_encode(array('refundAmount' => "{$amount}"));
} else {
$json = false;
}
Connection::getInstance()->sendRequest('orders/' . $orderCode . '/refund', $json, false);
}
示例7: delete
public function delete($school_id)
{
$conn = Connection::getInstance("write");
$command = "DELETE FROM newsletter\n\t\t\t\t\tWHERE news_id = {$this->id}\n\t\t\t\t\tAND school_id = {$school_id}";
if ($conn->execDelete($command)) {
return true;
} else {
return false;
}
}
示例8: editCategory6
public static function editCategory6($category)
{
$db = Connection::getInstance();
$mysqli = $db->getConnection();
$nic = $category->getNic();
$dateOfReturned = $category->getDateOfReturned();
$periodAboardStay = $category->getPerioadAbroadStay();
$reasonsForStay = $category->getReasonsForStay();
$query = "update personComingFromAboard set dateOfReturned='{$dateOfReturned}',periodAboardStay='{$periodAboardStay}',reasonsForStay='{$reasonsForStay}' where NIC='{$nic}'";
return $mysqli->query($query);
}
示例9: delete
public static function delete($id)
{
$db = Connection::getInstance();
// delete answer
require_once ROOT . DS . 'application' . DS . 'model' . DS . 'class.answer.php';
Answer::delete($id);
// delete thread
$sql = "DELETE FROM sse_thread WHERE thread_id = :id";
$statement = $db->prepare($sql);
$statement->execute(array(':id' => $id));
}
示例10: findAll
public static function findAll()
{
$database = Connection::getInstance();
$results = $database->run('SELECT * FROM chapters');
// Hydrate the objects
$chapters = array();
foreach ($results as $result) {
$chapters[] = self::factory($result);
}
return $chapters;
}
示例11: __construct
/**
* Initialize class
*
* @param string $host
* @param string $username
* @param string $passord
* @param string $database
* @return void
*/
public function __construct($host, $username = NULL, $password = NULL, $database = NULL, $newconnection = true)
{
$this->traitConstructor();
if (is_array($host)) {
$credentials = $host;
} else {
$credentials = ['host' => $host, 'username' => $username, 'password' => $password, 'database' => $database];
}
$this->connection = $newconnection ? new Connection($credentials) : Connection::getInstance() ?: new Connection($credentials);
$this->results = new Collection();
$this->query("SET NAMES UTF8");
}
示例12: DirectQuery
function DirectQuery($driver, $host = NULL, $dbname = NULL, $user = NULL, $pass = NULL)
{
if (Connection::validClass($driver)) {
$this->conn =& $driver;
} else {
if (URL::validclass($driver)) {
$this->conn =& Connection::getInstance($driver);
} else {
$this->conn =& Connection::getInstance($driver, $host, $dbname, $user, $pass);
}
}
}
示例13: __construct
/**
* Library constructor
* @param string $service_key
* Your worldpay service key
* @param int $timeout
* Connection timeout length
* */
public function __construct($service_key = false, $timeout = false)
{
if ($service_key == false) {
Error::throwError("key");
}
$this->connection = Connection::getInstance();
$this->setServiceKey($service_key);
if ($timeout !== false) {
$this->setTimeout($timeout);
}
//
}
示例14: exportCSV
function exportCSV($query, $headerArray, $filename)
{
$conn = Connection::getInstance();
$statement = $conn->db->prepare($query);
$statement->setFetchMode(PDO::FETCH_ASSOC);
$statement->execute();
$csv = Writer::createFromFileObject(new SplTempFileObject());
$csv->insertOne($headerArray);
$csv->insertAll($statement);
$csv->output($filename . '.csv');
die;
}
示例15: editPPAchievement
public static function editPPAchievement($achievement)
{
$db = Connection::getInstance();
$mysqli = $db->getConnection();
$schoolId = $achievement->getSchoolId();
$nic = $achievement->getNIC();
$achievementId = $achievement->getAchievementID();
$type = $achievement->getType();
$achievementDetail = $achievement->getAchievementDetail();
$query = "update pastpupil_Achievement set type='{$type}', achievementDetail='{$achievementDetail}' where schoolId='{$schoolId}' and NIC='{$nic}' and AchievementId='{$achievementId}'";
return $mysqli->query($query);
}