/** * Returns the list of currently executing queries * * @throws Exception * * @return array */ public function getCurrent() { $url = UrlHelper::buildUrl(Urls::URL_QUERY, array('current')); $response = $this->_connection->get($url); $result = $response->getJson(); return $result; }
public static function getTopList() { $connection = Connection::get(); $sql = ' SELECT u.*, SUM(IF(ug.type = "gold" AND ug.expire_date > NOW(), ug.amount - ug.used, 0)) AS gold, SUM(IF(ug.type = "coin" AND ug.expire_date > NOW(), ug.amount - ug.used, 0)) AS coin FROM users u LEFT JOIN user_gifts ug ON u.id = ug.user_id GROUP BY ug.user_id ORDER BY ( (SUM(IF(ug.type = "gold" AND ug.expire_date > NOW(), ug.amount - ug.used, 0)) * 10) + SUM(IF(ug.type = "coin" AND ug.expire_date > NOW(), ug.amount - ug.used, 0)) ) DESC '; $STH = $connection->prepare($sql); $STH->execute(); $users = array(); if ($STH->rowCount() > 0) { while ($row = $STH->fetch(PDO::FETCH_ASSOC)) { $user = new User(); $user->fillByArray($row); $userWallet = new UserWallet(); $userWallet->setUserId($user->getId()); $userWallet->setGold($row['gold']); $userWallet->setCoin($row['coin']); $user->setWallet($userWallet); $users[] = $user; } } return $users; }
/** * Yeah ! Tentative !! *Sans dec, je vais en chier. */ function validationDate($date_deb, $date_fin) { $conn = Connection::get(); // requete sql preparé $result = $conn->prepare("SELECT * FROM tarif_transaction WHERE date_deb >= :date_deb AND date_fin <= :date_fin"); echo var_dump($result); //TH : je fixe la date de fin car le menu deroulant ne permet pas de mettre 2015 (rien touché d'autre) //$date_fin="2015-12-31"; $result->execute(array('date_deb' => $date_deb, 'date_fin' => $date_fin)); $true = null; while ($row = $result->fetch()) { $true[] = $row; } //TH :et hop ici $true prend bien la bonne valeur (6 avec la base de max) echo "tadaaaaaaaaaa!"; echo var_dump($true); // Long story short, ça marche pas //$fakeresult = null; // array(2,2); //echo var_dump($fakeresult); if ($true != null) { // Ce test ne sert à rien s un resultat vide renvoit effectivement un null return $true; } else { return null; } }
public static function getNbType() { $conn = Connection::get(); $select = $conn->query("SELECT type_presentation.id_type as id, type_presentation.nom_type as type, count(presentation.id_presentation) as nb from type_presentation LEFT JOIN presentation on type_presentation.id_type = presentation.id_type GROUP BY type_presentation.id_type ORDER BY type_presentation.nom_type"); $result = array(); $result = $select->fetchAll(PDO::FETCH_ASSOC); return $result; }
public static function insererSurperso($array) { $conn = Connection::get(); var_dump($array); // requete d'insertion $request = $conn->prepare("INSERT INTO sur_perso (nom_beneficiaire, prenom_beneficiaire, evenement, nom_entp, id_carte)\n\t\t\t\tVALUES (:nom , :prenom , :evenement, :entreprise, 1)"); $request->execute($array); }
/** * @todo use static vars */ public function connection() { if (!$this->connected) { $this->connected = true; $this->setSource($this->table); } return Connection::get($this->connection); }
public static function insertOrateurNvEntp($nom_orateur, $prenom_orateur, $courriel_orateur, $tel_orateur) { $conn = Connection::get(); $entreprise = $conn->query("SELECT max(last_insert_id(id_entp)) as last_entp_inserted FROM entreprise"); $id_entreprise = $entreprise->fetch(); $req = $conn->prepare("INSERT INTO orateur (nom_orateur, prenom_orateur, courriel_orateur, tel_orateur, id_entp) VALUES (:nom_orateur, :prenom_orateur, :courriel_orateur, :tel_orateur, :id_entp)"); $req->execute(array('nom_orateur' => $nom_orateur, 'prenom_orateur' => $prenom_orateur, 'courriel_orateur' => $courriel_orateur, 'tel_orateur' => $tel_orateur, 'id_entp' => $id_entreprise['last_entp_inserted'])); }
/** * Get registered user functions * * The method can optionally be passed a $namespace parameter to narrow the results down to a specific namespace. * * @param null $namespace * * @throws Exception throw exception if the request failed * * @return mixed true if successful without a return value or the return value if one was set in the action */ public function getRegisteredUserFunctions($namespace = null) { $url = UrlHelper::buildUrl(Urls::URL_AQL_USER_FUNCTION, array()); if (!is_null($namespace)) { $url = UrlHelper::appendParamsUrl($url, array('namespace' => $namespace)); } $response = $this->_connection->get($url); $responseArray = $response->getJson(); return $responseArray; }
public function __construct() { $this->stat = explode(' ', file_get_contents('/proc/self/stat')); $this->ts = microtime(true); self::$obj = $this; $this->script = $_SERVER['PHP_SELF']; $this->disabled = Connection::get()->isFailed(); //если нет соединения, отключаем сбор счётчиков $this->conn = Connection::get(); }
/** * Método que irá abrir uma conexão com servidor. * * @param <string> $name >> nome da conexão. */ static function connection($name) { $config = Connection::get($name); # iniciando conexão, caso isto ainda não tenha sido feito. if (!array_key_exists('connection', $config)) { Connection::$connections[$name]['connection'] = pg_connect("host={$config['host']} port={$config['port']} dbname={$config['database']} user={$config['user']} password={$config['password']}"); pg_set_client_encoding(Connection::$connections[$name]['connection'], 'UTF-8'); } return Connection::$connections[$name]['connection']; }
public static function contratConcerne($dateDeb, $dateFin) { $conn = Connection::get(); $select = $conn->query("SELECT id_tarif, prix, date_deb, date_fin, nbcarte_max, nbcarte_min FROM tarif_transaction WHERE ((DATEDIFF(date_fin, '" . $dateDeb . "') >=0) AND (DATEDIFF(date_fin, '" . $dateFin . "') <=0) )OR ((DATEDIFF(date_deb, '" . $dateFin . "') <=0) AND (DATEDIFF(date_fin, '" . $dateDeb . "') >=0) ) ORDER BY date_deb ASC"); $result = array(); while ($row = $select->fetch()) { $result[] = $row; } return $result; }
public static function novoCiclo($codConta, $data) { $con = Connection::get(); $prepared = $con->prepare("INSERT INTO Ciclos VALUES (NULL, :di, :code)"); $prepared->bindParam(":di", $data); $prepared->bindParam(":code", $codConta); $prepared->execute(); $prepared = null; $con = null; }
public static function getLibById($id_grp) { $result = null; $conn = Connection::get(); // requete sql preparé $request = $conn->prepare("SELECT id_grp, lib_grp FROM groupe WHERE id_grp=:id_grp"); $request->execute(array('id_grp' => $id_grp)); while ($row = $request->fetch()) { $result[] = $row; } return $result; }
public static function adicionar($nome, $categoria, $temporaria) { $conn = Connection::get(); $prepared = $conn->prepare("INSERT INTO Fotos VALUES (:nome, :categoria, NOW(), :temporaria)"); $prepared->bindParam(":nome", $nome); $prepared->bindParam(":categoria", $categoria); $prepared->bindParam(":temporaria", $temporaria); $prepared->execute(); $prepared = null; $conn = null; return true; }
public static function getLibById($id_mag) { $conn = Connection::get(); // requete sql preparé $request = $conn->prepare("SELECT lib_mag FROM entite WHERE id_mag=:id_mag"); $request->execute(array('id_mag' => $id_mag)); $result = null; while ($row = $request->fetch()) { $result[] = $row; } return $result; }
/** * Método que irá abrir uma conexão com servidor. * * @param <string> $name >> nome da conexão. */ static function connection($connection = 'default') { $config = Connection::get($connection); if (!array_key_exists('connection', $config)) { # criando arquivo do SQLite if (!($conn = new PDO("sqlite:{$config['path']}{$config['database']}.db"))) { die('SQLite: Erro ao se conectar.'); } $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); Connection::$connections[$connection]['connection'] = $conn; } return Connection::$connections[$connection]['connection']; }
public static function getSubjectInfo($id_predmet) { $dbh = Connection::get(); $query = "SELECT nazov,kod FROM predmet WHERE id = \$1"; $dbh->query($query, array($id_predmet)); if ($dbh->RowCount() > 0) { $predmet = $dbh->fetch_assoc(); $dbh->Release(); return "{$predmet["nazov"]}({$predmet["kod"]})"; } else { return ""; } }
/** * @param string $model * @return Store * @throws Exception */ public static function get(string $model) : self { if (!array_key_exists($model, self::$namespaces)) { self::$namespaces[$model] = reset(self::$namespaces); } if (!array_key_exists($model, self::$stores)) { $class = self::$namespaces[$model] . '\\Store\\' . $model . 'Store'; if (!class_exists($class)) { throw new Exception('Invalid or missing namespace for model ' . $model); } self::$stores[$model] = new $class(Connection::get()); } return self::$stores[$model]; }
/** * From an ajax call, send all the data back to the homepage when loading */ public function index() { $db = Connection::get(); $dishManager = new DishManager($db); if (isset($_GET["data"]) && $_GET["data"] === "featureddishes") { $list = $dishManager->getFeaturedList(); $return = array(); foreach ($list as $value) { $val = $value->objectToArray(); $return[] = $val; } } echo json_encode($return); }
public static function __callstatic($name, $arguments) { $db = Config::get('database.' . static::$config); $db['connection'] = static::$config; $connection = Connection::get($db); $builder = new Builder($connection, $db, static::$table, static::$primary_key, static::class); if ($name == 'first' || $name == 'get' || $name == 'pluck') { return $builder->{$name}(); } if ($name == 'lists' || $name == 'create') { return $builder->{$name}($arguments[0]); } call_user_func_array(array($builder, $name), $arguments); return $builder; }
public static function criar($ciclo, $data) { $con = Connection::get(); $prepared = $con->prepare("INSERT INTO Dias(codCiclo, data) VALUES (:ci, :da)"); $prepared->bindParam(":ci", $ciclo); $prepared->bindParam(":da", $data); $prepared->execute(); $prepared = null; $codDia = $con->lastInsertId(); $con->prepare("INSERT INTO Temperaturas(codDia) VALUES ({$codDia})")->execute(); $con->prepare("INSERT INTO ColoUtero(codDia) VALUES ({$codDia})")->execute(); $con->prepare("INSERT INTO Mucos(codDia) VALUES ({$codDia})")->execute(); $con->prepare("INSERT INTO Sangramentos(codDia) VALUES ({$codDia})")->execute(); return self::obter; }
public static function isAuthenticated() { if (array_key_exists("cod_user", $_SESSION) && $_SESSION['cod_user'] > 0) { $con = Connection::get(); $prepared = $con->prepare("SELECT 1 FROM Contas WHERE codigo=:code"); $prepared->bindParam(":code", $_SESSION['cod_user']); $prepared->execute(); $result = $prepared->fetch(); $prepared = null; $con = null; if ($result) { return true; } } return false; }
function displayContent($condition = null) { include 'classes/Event.php'; $connection = Connection::get(); $sentenceSQL = "select * from Events"; if ($condition != null) { $sentenceSQL .= " where category = " . $condition; } $sentenceSQL .= " limit 30"; $results = $connection->select($sentenceSQL); while ($evt = $results->fetch_assoc()) { $event = new Event($evt['id'], $evt['user'], $evt['category'], $evt['name'], $evt['address'], $evt['city'], $evt['description'], $evt['dateStart'], $evt['dateEnd'], $evt['img'], $evt['public'], $evt['offer']); echo '<div class="col s12 m4">'; $event->paintEvent(); echo '</div>'; } }
function saveDetails() { $this->mysqli = Connection::get(); $response = array(); $path = "albums/"; if (!file_exists($path)) { mkdir($path); } $imageUpload = new ImageUpload($this->image); $imageUpload->dstPath = $path; if ($imageUpload->save()) { //ImageUpload class by default saves all the image to jpg $imagePath = $path . $this->image . ".jpg"; $sql = "INSERT INTO android(id, image, location) VALUES (1,'{$this->location}','{$imagePath}')"; if ($result = $this->mysqli->query($sql)) { $response = BaseClass::createResponse(1, "Details Saved"); } } else { return $imageUpload->response; } //End return $response; }
/** * Retrieves information about the current database * * This will get information about the currently used database from the server * * @param Connection $connection - the connection to be used * * @link http://www.arangodb.com/manuals/1.4/HttpDatabase.html * * @return array $responseArray - The response array. */ public static function getInfo(Connection $connection) { $url = UrlHelper::buildUrl(Urls::URL_DATABASE, array('current')); $response = $connection->get($url); $responseArray = $response->getJson(); return $responseArray; }
public static function insertEntreprise($nom_entreprise, $adresse_entreprise, $imgName, $url_entreprise) { $conn = Connection::get(); $req = $conn->prepare('INSERT INTO entreprise (nom_entp, adresse_entp, url_entp, logo_entp) VALUES ("' . $nom_entreprise . '","' . $adresse_entreprise . '","' . $url_entreprise . '","' . $imgName . '")'); $req->execute(array('nom_entp' => $nom_entreprise, 'adresse_entp' => $adresse_entreprise, 'url_entp' => $url_entreprise, 'logo_entp' => $imgName)); }
private function dumpDebugInfo() { $dbh = Connection::get(); $time = 0; $table = array(array('SQL Statement', 'Time', 'Result')); foreach ($dbh->sql_history as $sql) { $table[] = $sql; $time += $sql[1]; } $query_count = count($dbh->sql_history); fb(array("{$query_count} queries took {$time} seconds", $table), FirePHP::TABLE); // dump session $table = array(array('Key', 'Value')); foreach (array_keys($_SESSION) as $key) { $table[] = array($key, $_SESSION[$key]); } fb(array('Session (' . count($_SESSION) . ' items)', $table), FirePHP::TABLE); }
public static function insertOrganisateur($soc_orga, $nom_orga, $prenom_orga, $courriel_orga, $tel_orga, $id_evnt) { $conn = Connection::get(); $req = $conn->prepare('INSERT INTO organisateur (societe_organisateur, nom_organisateur, prenom_organisateur, courriel_organisateur, tel_organisateur) VALUES ("' . $soc_orga . '","' . $nom_orga . '","' . $prenom_orga . '","' . $courriel_orga . '","' . $tel_orga . '")'); $req->execute(array('societe_organisateur' => $soc_orga, 'nom_organisateur' => $nom_orga, 'prenom_organisateur' => $prenom_orga, 'courriel_organisateur' => $courriel_orga, 'tel_organisateur' => $tel_orga)); }
$connection = Connection::get(); $dateStart = $_POST['dateStart'] . " " . $_POST['timeStart'] . ":00"; $dateEnd = $_POST['dateEnd'] . " " . $_POST['timeEnd'] . ":00"; $results = $connection->select("select id from Cities where name = '{$_POST['city']}'"); $city = $results->fetch_assoc()['id']; $values = ['id' => $_POST['id'], 'user' => $_SESSION['id'], 'category' => $_POST['category'], 'name' => $_POST['name'], 'address' => $_POST['address'], 'city' => $city, 'description' => $_POST['description'], 'dateStart' => $dateStart, 'dateEnd' => $dateEnd, 'img' => $_POST['image'], 'public' => 1, 'offer' => $_POST['offer']]; $connection->update("event", $values, ["id" => $_POST['id']]); } } ?> <div class="container"> <div class="row"> <ul class="collapsible popout" data-collapsible="accordion"> <?php include 'classes/Event.php'; $connection = Connection::get(); $results = $connection->select("select * from Events where user = {$_SESSION['id']}"); while ($evt = $results->fetch_assoc()) { $event = new Event($evt['id'], $evt['user'], $evt['category'], $evt['name'], $evt['address'], $evt['city'], $evt['description'], $evt['dateStart'], $evt['dateEnd'], $evt['img'], $evt['public'], $evt['offer']); $event->paintUserEvents(); } ?> </ul> </div> </div> </main> <?php include 'components/Footer.php'; ?>
<?php /** * Created by PhpStorm. * User: eduardo * Date: 29/11/15 * Time: 11:02 */ require_once 'classes/Connection.php'; $c = Connection::get(); /************************************************************************************************* * IMPORTANT $task, $arguments[], $conditions[] or null ++++++++++++++++++++++++++++++++++++++++++ ************************************************************************************************/ /**FORMATS TO Insert * $c->insert("user", ["name"=>'ONE', "surname"=>'ONE', "password"=>'test', "email"=>'*****@*****.**'], null); * $c->insert("category", ["name"=>'test'], null); * $c->insert("event", ["user"=>'1001',"category"=>'5',"name"=>'Un evento asociado a un usuario',"address"=>'Una direccion pa quedar',"city"=>'100', "description"=>'Barbacoa en mi casa este finde...', "dateStart"=>'2015-01-02 12:12:12', "dateEnd"=>'2015-10-10 12:12:12', "img"=>'100.jpg', "public"=>'1', "offer"=>'cerveza gratis!'], null); */ /**FORMATS TO Update * $c->update("user",["name"=>'change',"surname"=>'change',"password"=>'change',"email"=>'*****@*****.**'],["id"=>'5000']); * $c->update("category",["name"=>'Informatica'],["id"=>'5']); * $c->update("event", ["user"=>'5',"category"=>'5',"name"=>'Un evento asociado a un usuario',"address"=>'Una direccion pa quedar',"city"=>'100', "description"=>'Barbacoa en mi casa este finde...', "dateStart"=>'2015-01-02 12:12:12', "dateEnd"=>'2015-10-10 12:12:12', "img"=>'100.jpg', "public"=>'1', "offer"=>'cerveza gratis!'], ["id"=>'1504']); */ /**FORMATS TO Delete *$c->delete("user", ["id"=>'1498'], null); *$c->delete("category", ["id"=>'1498'], null); *$c->delete("event", ["id"=>'1498'], null); */ $c->delete("event", ["id" => '1498'], null);