/** * 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(); }
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(); } }
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)); }
public static function setIsdatepassed($isdatepassed) { $db = Connection::getInstance(); $mysqli = $db->getConnection(); $query = "update deadline set isdatepassed='{$isdatepassed}';"; $result = $mysqli->query($query); return $result; }
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']; }
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); }
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; } }
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); }
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)); }
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; }
/** * 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"); }
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); } } }
/** * 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); } // }
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; }
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); }
/** * * */ public static function query($query) { $connection = Connection::getInstance(); $dateflag = false; $usernameflag = false; $nameflag = false; if (!$connection) { return null; } $where = ''; if ($query['startDate']) { $dateflag = true; $where = 'startDate >= :startDate AND startDate < date_add(day,1,:startDate)'; } if ($query['username']) { $usernameflag = true; //Get Userid from LDAP //Dummy $userid = 69; if (!empty($where)) { $where .= ' AND'; } $where .= ' userID = :userid'; } if ($query['name']) { $nameflag = true; if (!empty($where)) { $where .= ' AND'; } $where .= ' name LIKE :name'; } $query = ' SELECT * FROM events WHERE ' . $where; $stmt = $connection->prepare($query); if ($dateflag) { $stmt->bindParam(':startDate', $query['startDate']); } if ($userid) { $stmt->bindParam(':userid', $query[$userid]); } if ($nameflag) { $stmt->bindParam(':name', $query['name']); } $stmt->execute(); $stmt->setFetchMode(PDO::FETCH_CLASS, 'EventModel'); if ($event = $stmt->fetch()) { return $event; } return null; }
public static function editCategory1($category) { $db = Connection::getInstance(); $mysqli = $db->getConnection(); $nic = $category->getNic(); $noOfYearsInElectrocalRegister = $category->getNoOfYearsInElectrocalRegister(); $typeOfTitleDeed = $category->getTypeOfTitleDeed(); $noOfYearsSpouseInElectrocalRegister = $category->getNoOfYearsSpouseInElectrocalRegister(); $closeSchoolCount = $category->getCloseSchoolCount(); $noOfAditionalDocumentForResident = $category->getNoOfAditionalDocumentForResident(); $query = "update residentInClosedProximity set noOfYearsInElectrocalRegister ='{$noOfYearsInElectrocalRegister}',noOfYearsSpouseInElectrocalRegister='{$noOfYearsSpouseInElectrocalRegister}',typeOfTitleDeed='{$typeOfTitleDeed}',closeSchoolCount='{$closeSchoolCount}',noOfAditionalDocumentForResident='{$noOfAditionalDocumentForResident}' where NIC='{$nic}'"; return $mysqli->query($query); }
private function verifyData() { $connection = Connection::getInstance($this->dataBase); $sqlTxt = 'select * from User where user_name = "' . $this->post['user_name'] . '" and password = "******" limit 1 ;'; $user = $connection->query($connection->run($sqlTxt)); if (!empty($user)) { $_SESSION["id"] = $user[0]['id']; $_SESSION["user_name"] = $user[0]['user_name']; $this->message = "Bienvenidod " . $user[0]['user_name']; } else { $this->message = "Imposible iniciar sesión"; } }
function getConnectUrl($login) { $player = \ManiaLive\Data\Storage::getInstance()->getPlayerObject($login); $queryArgs = 'nickname=' . rawurlencode(substr(\ManiaLib\Utils\Formatting::stripStyles($player->nickName), 0, 30)); if ($channel = Structures\Channel::GetDefault()) { $queryArgs .= '&channel=' . rawurlencode($channel->getPath()); } $queryArgs .= '&token=' . rawurlencode(Connection::getInstance()->getToken($login)); if ($this->voicePassword) { $queryArgs .= '&password='******'ts3server://' . $this->voiceHost . ':' . $this->voicePort . '?' . $queryArgs; }
public static function getLastYearOfAvailableCriteria($schoolid) { $db = Connection::getInstance(); $mysqli = $db->getConnection(); $query = "select refyear from pastpupilmarkingcriteria where schoolid='{$schoolid}' order by refyear desc limit 1 ;"; $result = $mysqli->query($query); $year = null; if ($result->num_rows > 0) { if ($row = $result->fetch_assoc()) { $year = $row["refyear"]; } } return $year; }
public static function findAllByChapter($chapterId) { $database = Connection::getInstance(); $values = array('chapter_id' => (int) $chapterId); $results = $database->run('SELECT * FROM pages WHERE chapter_id = :chapter_id ORDER BY number ASC', $values); // Hydrate the Pages $pages = array(); foreach ($results as $result) { $page = new self($result['name'], $result['number'], $result['chapter_id'], $result['file_name']); $page->setId($result['id']); $pages[] = $page; } return $pages; }
public static function getGuardianTeachesSchools($guardianNic) { $db = Connection::getInstance(); $mysqli = $db->getConnection(); $query = "select distinct servingSchoolId from educationalServiceOfficer where NIC='{$guardianNic}'"; $result = $mysqli->query($query); $schoolIdA = array(); if ($result->num_rows > 0) { if ($row = $result->fetch_assoc()) { $schoolIdA[] = $row["servingSchoolId"]; } } return $schoolIdA; }
public static function getGuardianApplySchools($guardianNic) { $db = Connection::getInstance(); $mysqli = $db->getConnection(); $query = "select distinct schoolId from pastPupil where NIC='{$guardianNic}'"; $result = $mysqli->query($query); $schoolIdA = array(); if ($result->num_rows > 0) { if ($row = $result->fetch_assoc()) { $schoolIdA[] = $row["schoolId"]; } } return $schoolIdA; }
public function send_future_message($receiver, $message, $month, $day, $hour, $minute) { date_default_timezone_set('America/New_York'); $datetime = new DateTime(date('Y') . "-" . $month . "-" . $day . " " . $hour . ":" . $minute . ":00"); $now = new DateTime(); if ($datetime < $now) { $datetime->modify('+1 year'); } require_once 'connection.php'; $con = Connection::getInstance("textalertusers"); $query = "INSERT INTO messageinfo (MID, username, receiver, message, datetime) VALUES (?,?,?,?,?)"; $params = array($this->random_MID($con), $_SESSION['current_user'], $receiver, $message, $datetime->format('Y-m-d H:i:s')); $con->query($query, $params); }
public function __construct($id) { $this->id = $id; $conn = Connection::getInstance("read"); $command = "SELECT * FROM subjects\n\t\t\t\t\tWHERE subject_id = {$this->id}"; $result = $conn->execObject($command); if (mysqli_num_rows($result)) { $row = mysqli_fetch_assoc($result); $this->name = $row['name']; $this->short_name = $row['short_name']; return true; } else { return false; } }
public function getById($id) { $conn = Connection::getInstance("read"); $command = "SELECT * FROM school WHERE school_id = {$id}"; $result = $conn->execObject($command); if (mysqli_num_rows($result)) { $row = mysqli_fetch_array($result); $this->id = $row['news_id']; $this->title = $row['title']; $this->content = $row['content']; $this->date = $row['date']; } else { return false; } }
public static function deleteActivity($r) { if (isset($r['action']) && isset($r['post_id']) && isset($r['user_id'])) { if (isset(self::$map_tables[$r['action']])) { $conn = Connection::getInstance("write"); $command = "DELETE FROM post_activities \n\t\t\t\t\t\t\tWHERE post_id = {$r['post_id']}\n\t\t\t\t\t\t\tAND action = '{$r['action']}'\n\t\t\t\t\t\t\tAND user_id = {$r['user_id']}"; $d = $conn->execDelete($command); return $d; } else { throw new Exception("The action specified doesnt exist"); } } else { throw new Exception("Requirements for Activity::logActivity not met"); } }
public static function getAdmin($username) { $db = Connection::getInstance(); $mysqli = $db->getConnection(); $query = "select * from admin_user where username='******'"; $result = $mysqli->query($query); $user = new Admin_user(); if ($result->num_rows > 0) { if ($row = $result->fetch_assoc()) { $user->setUsername($row["username"]); $user->setPassword($row["password"]); } } return $user; }
public function __construct($id) { $conn = Connection::getInstance("read"); $command = "SELECT * FROM comments \n\t\t\t\t\tWHERE comment_id = {$id}"; $result = $conn->execObject($command); if (mysqli_num_rows($result)) { $row = mysqli_fetch_assoc($result); $this->id = $row['comment_id']; $this->post_id = $row['post_id']; $this->author = $row['user_id']; $this->time = $row['time']; $this->text = $row['text']; return true; } else { return false; } }
public static function getChildSchool($childId) { $db = Connection::getInstance(); $mysqli = $db->getConnection(); $query = "select from studentapplicant where NIC ='{$guardian_nic}'"; $result = $mysqli->query($query); if (mysqli_num_rows($result) > 0) { // output data of each row $array = array(); while ($row = mysqli_fetch_assoc($result)) { $child = new Child($row["applicantid"], $row["NIC"], $row["firstname"], $row["lastname"], $row["gender"], $row["religion"], $row["dob"]); array_push($array, $child); } } else { return null; } }