本文整理汇总了PHP中DBConnector::createConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP DBConnector::createConnection方法的具体用法?PHP DBConnector::createConnection怎么用?PHP DBConnector::createConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBConnector
的用法示例。
在下文中一共展示了DBConnector::createConnection方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deletePhoto
public function deletePhoto($userId)
{
$connector = new DBConnector();
$connection = $connector->createConnection();
$query = 'DELETE FROM photo WHERE fk_id_user=' . $userId;
mysql_query($query) or die("Error in query: {$query}. " . mysql_error());
mysql_close($connection);
}
示例2: deleteQueryByID
public function deleteQueryByID($queryID)
{
$connector = new DBConnector();
$connection = $connector->createConnection();
$query = "DELETE FROM queries WHERE id={$queryID}";
mysql_query($query) or die("Error in query: {$query}. " . mysql_error());
mysql_close($connection);
return $queryID;
}
示例3: getStatisticTitleById
public function getStatisticTitleById($sid)
{
$connector = new DBConnector();
$connection = $connector->createConnection();
$query = 'SELECT title FROM statistics WHERE id=' . $sid;
$result = mysql_query($query) or die("Error in " . $query);
$row = mysql_fetch_assoc($result);
$title = $row['title'];
mysql_free_result($result);
mysql_close($connection);
return $title;
}
示例4: loadAllComments
public function loadAllComments($qId)
{
$connector = new DBConnector();
$connection = $connector->createConnection();
$result = mysql_query("SELECT * FROM comment WHERE FK_queryId='{$qId}'") or die("Error");
//TODO DATE
$ans = array();
while ($row = mysql_fetch_assoc($result)) {
$ans[$row['id']] = $row['text'];
}
mysql_free_result($result);
mysql_close($connection);
return $ans;
}
示例5: getMessage
public function getMessage($mid)
{
$connector = new DBConnector();
$connection = $connector->createConnection();
$result = mysql_query("SELECT * FROM messages WHERE message_id = '{$mid}'");
$message = mysql_fetch_array($result);
$ans = array();
$ans['title'] = $message['message_title'];
$ans['from'] = $message['from_user'];
$ans['content'] = $message['message_contents'];
mysql_free_result($result);
mysql_close($connection);
return $ans;
}
示例6: modifyUserInfo
/**
*
* @param <type> $id the user id to modify the values here
* @param <type> $userInstanceNewValues the new values of the user info
* that are in the user instance
*/
public function modifyUserInfo($id, $userInstanceNewValues)
{
$connector = new DBConnector();
$connection = $connector->createConnection();
$userId = $userInstanceNewValues->getId();
$gender = $userInstanceNewValues->gender;
$maritalStatus = $userInstanceNewValues->maritalSt;
$studies = $userInstanceNewValues->studies;
$institutionName = $userInstanceNewValues->getInstitutionName();
$country = $userInstanceNewValues->getCountry();
$religion = $userInstanceNewValues->getReligion();
$query = "UPDATE userinfo set gender='" . $gender . "', maritalSt='" . $maritalStatus . "', studies='" . $studies . "' , InstitutionName='" . $institutionName . "' , currentLocation='" . $country . "' , religion='" . $religion . "' where FK_users=" . $userId;
mysql_query($query) or die("Error in query modifying user info : {$query}. " . mysql_error() . " and the user id is" . $id);
mysql_close($connection);
}
示例7: selectAnswersByQueryId
public function selectAnswersByQueryId($qid)
{
$connector = new DBConnector();
$connection = $connector->createConnection();
$ans = array();
$query = 'SELECT id FROM qanswer where FK_queries = ' . $qid;
$result = mysql_query($query) or die("Error in query: {$query}. " . mysql_error());
$ix = 0;
while ($answer = mysql_fetch_assoc($result)) {
$ans[$ix++] = $answer['id'];
}
mysql_free_result($result);
mysql_close($connection);
return $ans;
}
示例8: DBConnector
<?php
require_once '../util.php';
require_db();
$connector = new DBConnector();
$connection = $connector->createConnection();
$name = "photo1";
$extension = "jpg";
$path = "path";
$userId = 1;
$size = 123;
$query = "INSERT INTO photo (name,extension,path,fk_id_user,size_kb) VALUE ('{$name}','{$extension}','{$path}','{$userId}', '{$size}');";
$result = mysql_query($query);
if (!$result) {
return "error photo";
}
$userId = 12;
$query = 'DELETE FROM photo WHERE fk_id_user=' . $userId;
$result = mysql_query($query);
$rowsMysql = mysql_affected_rows();
if ($rowsMysql < 0) {
return "error i cant delete more records";
}
if (!$result) {
return "error photo";
}
mysql_close($connection);
class DBConnector
{
function createConnection()
{
示例9: newTracking
public function newTracking($follower, $followed)
{
$connector = new DBConnector();
$connection = $connector->createConnection();
$date = date('Y-m-d H:i:s');
$query = "INSERT INTO trackings (followedId, followerId, approved, notified, date) VALUES ({$followed}, {$follower}, 0, 0, '{$date}')";
mysql_query($query) or die("Error");
$tid = mysql_insert_id();
mysql_close($connection);
return $tid;
}
示例10: initTransaction
public function initTransaction()
{
$connector = new DBConnector();
$this->connection = $connector->createConnection();
}