/** * Get user profile * * @access public * @param resource $ldap * @param string $baseDn * @param string $query * @return array */ public function getProfile($ldap, $baseDn, $query) { $this->query->execute($ldap, $baseDn, $query, $this->getAttributes()); $profile = array(); if ($this->query->hasResult()) { $profile = $this->prepareProfile(); } return $profile; }
public function testExecuteQueryFailed() { self::$functions->expects($this->once())->method('ldap_search')->with($this->equalTo('my_ldap_resource'), $this->equalTo('ou=People,dc=kanboard,dc=local'), $this->equalTo('uid=my_user'), $this->equalTo(array('displayname')))->will($this->returnValue(false)); $query = new Query(); $query->execute('my_ldap_resource', 'ou=People,dc=kanboard,dc=local', 'uid=my_user', array('displayname')); $this->assertFalse($query->hasResult()); }
public function toArray() { $data = $this->_cache->getData(); // print_r($data); if (empty($data)) { $query = new Query($this->_callChain); try { $data = $query->execute(); if (! empty($data)) { $this->_cache->populate($data[0]); } $data = $this->_cache->getData(); } catch (Exception $e) { throw $e; } } return $data; }
/** * Gets a Role object * * @param id the Role Id * @return the Role object */ function &get($id) { $query = new Query("Role"); $criteria = new Criteria($query, "ID", $id); $query->setCriterion($criteria); return $this->mapOne($query->execute()); }
public function execute(array $parameters = array(), array $options = array()) { if ($stmt = parent::execute($parameters, $options)) { return $stmt->rowCount(); } return $stmt; }
/** * Gets RoleUser objects by a roleId * * @param $roleId role id looked up * @return Array - array with RoleUser objects */ function &findByRoleId($roleId) { $query = new Query("RoleUser"); $criteria = new Criteria($query, "roleID", $roleId); $query->setCriterion($criteria); return $this->mapAll($query->execute()); }
/** * Gets the classes whose objects the user can execute certain action * * @param $action object - The action that the user should be allowed to do * @param $user User - The user that holds de permissions * @return Array - an array of class objects */ function &findByPermission($action, $user) { $classQuery = new Query("Class"); // Navigate relationships $folderClassQuery =& $classQuery->queryRelationedClass("FolderClass"); $permissionQuery =& $folderClassQuery->queryRelationedClass("Permission"); $actionQuery =& $permissionQuery->queryRelationedClass("Action", Relationship::ManyToOneType()); $roleQuery =& $permissionQuery->queryRelationedClass("Role", Relationship::ManyToOneType()); $roleUserQuery =& $roleQuery->queryRelationedClass("RoleUser"); $userQuery =& $roleUserQuery->queryRelationedClass("User", Relationship::ManyToOneType()); // Criterias $criteriaGroup = new CriteriaGroup(); $actionCriteria = new Criteria($actionQuery, "action", $action->getAction()); $userCriteria = new Criteria($userQuery, "ID", $user->getId()); $criteriaGroup->addCriterion($actionCriteria); $criteriaGroup->addCriterion($userCriteria); $classQuery->setCriterion($criteriaGroup); // sorting $order = new Order($classQuery, "title", "ASC"); $classQuery->addOrder($order); // Execute the query $recordset =& $classQuery->execute(); $array = $this->mapAll($recordset); return $array; }
/** * Gets a list with permissions for a folderClass object * @param $folderClassId FolderClass - the folderClass object * @return Array with permission objects */ function findByFolderClassId($folderClassId) { $query = new Query("Permission"); $criteria = new Criteria($query, "folderClassID", $folderClassId); $query->setCriterion($criteria); return $this->mapAll($query->execute()); }
/** * Gets a class' attributes * * @param classId id of a class * @return array of class objects */ function findByClassId($classId) { $query = new Query("ClassAttribute"); $criteria = new Criteria($query, "classID", $classId); $query->setCriterion($criteria); $order = new Order($query, "position", Order::OrderTypeAsc()); $query->addOrder($order); return $this->mapAll($query->execute()); }
public function testBadData() { $path = __DIR__ . '/fixtures/datastore/querytest'; $config = new Config($path . '/'); $repo = new Repository('baddata', $config); $query = new Query($repo); $result = $query->execute(); $this->assertEquals(1, count($result)); }
/** * Load the next round of models. */ private function loadModels() { $start = $this->rangeStart($this->pointer, $this->limit); if ($this->loadedStart !== $start) { $this->query->start($start); $this->models = $this->query->execute(); $this->loadedStart = $start; } }
/** * Execution method * Bypasses constructor subject if value provided * @param mixed $value * @return array */ public function execute($value = null) { if (is_null($value)) { if (empty($this->subject)) { return $value; } $value = $this->subject; } return parent::execute($value); }
public function count() { $this->count = true; if ($count = $this->getDataCache()) { return $count; } $count = parent::execute()->count(); $this->setDataCache($count); return $count; }
/** * Checks the cache to see if this query exists and returns it. If it's * not in the cache then the query is run, stored and then returned. * * @return Result The result of the query. */ public function execute() { // Generate a cache key by comparing our parameters to see if we've // made this query before $key = $this->getParameterHash() . $this->getFileHash(); // Try and fetch a cached result object from APC $result = apc_fetch($key, $success); // If the result isn't in the cache then we run the real query if (!$success) { $result = parent::execute(); apc_store($key, $result); } return $result; }
function isPlay($idJoueur, $idTournoi, $database) { $sql_func = 'SELECT * FROM joueurtournoi WHERE id_joueur = :id_joueur AND id_tournoi = :id_tournoi'; $query_func = new Query($database, $sql_func); $query_func->bind(':id_joueur', $idJoueur, PDO::PARAM_INT); $query_func->bind(':id_tournoi', $idTournoi, PDO::PARAM_INT); if ($query_func->execute()) { $jeux = $query_func->getResult(); } if (empty($jeux)) { //ne joue pas a ce jeux return 0; } else { //joue a ce jeux return 1; } }
/** * Execution method, with different result handling * @param mixed $value * @return mixed */ public function execute($value = null) { if (is_null($value)) { if (empty($this->subject)) { return $value; } $value = $this->subject; } $original = (array) $value; $data = (array) $value; $result = parent::execute($data); foreach ($original as $key => $val) { if (!isset($result[$key])) { unset($value->{$key}); } elseif ($result[$key] !== $value->{$key}) { $value->{$key} = $result[$key]; } } return $value; }
/** * Checks the cache to see if this query exists and returns it. If it's * not in the cache then the query is run, stored and then returned. * * @return Result The result of the query. */ public function execute() { static $apcPrefix = null; if ($apcPrefix === null) { $apcPrefix = function_exists('apcu_fetch') ? 'apcu' : 'apc'; } // Generate a cache key by comparing our parameters to see if we've // made this query before $key = $this->getParameterHash() . $this->getFileHash(); // Try and fetch a cached result object from APC $funcName = $apcPrefix . '_fetch'; $success = false; $result = $funcName($key, $success); // If the result isn't in the cache then we run the real query if (!$success) { $result = parent::execute(); $funcName = $apcPrefix . '_store'; $funcName($key, $result); } return $result; }
<?php /** * Installs all tables in the mysql.sql file, using the default mysql connection * Change and uncomment this when you need to: */ /* mysql_connect('localhost', 'root'); if (mysql_errno()) { die(' Error '.mysql_errno().': '.mysql_error()); } mysql_select_db('test'); */ require_once dirname(dirname(__FILE__)) . "/Query.class.php"; $sql = file_get_contents('vendor/zorrodg/oauth-php/src/OAuth1/store/mysql/mysql.sql'); $ps = explode('#--SPLIT--', $sql); foreach ($ps as $p) { $p = preg_replace('/^\\s*#.*$/m', '', $p); Query::execute(array("q" => $p), FALSE); }
public function save() { $updateData = []; foreach (static::$schema as $key => $value) { if ($key != 'id') { $updateData[$key] = self::parseToSql($value['type'], $this->{$key}); } } $execParams = array_values($updateData); // exists if ($this->id) { $rq = "UPDATE " . self::getTableName() . " SET "; // create field assoc $tmp = []; foreach ($updateData as $key => $value) { $tmp[] = "{$key} = ?"; } $rq .= implode(', ', $tmp); $rq .= ' WHERE id = ?'; $execParams[] = $this->id; $saveQ = new Query($rq); $saveQ->execute($execParams); } else { $rq = "INSERT INTO " . self::getTableName() . " (" . implode(', ', array_keys($updateData)) . ") " . "VALUES (" . implode(', ', array_fill(0, count($updateData), '?')) . ")"; $saveQ = new Query($rq); $saveQ->execute($execParams); $this->id = intval(Query::getConnexion()->lastInsertId()); } }
$nbrmax = $nbrm; } } $cpt++; $matches[$match['id_match']][$cpt]['id'] = $ligne['id_joueur']; $matches[$match['id_match']][$cpt]['nom'] = $ligne['pseudo']; $matches[$match['id_match']][$cpt]['score'] = $ligne['score']; /* For every Match and Joueur proceeded, get the Manches corresponding */ $sql3 = 'SELECT mj.numero_manche, mj.score FROM manches_joueurs as mj WHERE mj.id_match=:idm AND mj.id_joueur=:idj'; $query3 = new Query($database, $sql3); $query3->bind('idm', $match['id_match'], PDO::PARAM_INT); $query3->bind('idj', $ligne['id_joueur'], PDO::PARAM_INT); if ($query3->execute()) { foreach ($query3->getResult() as $ligne) { $scores[$match['id_match']][$cpt]['scores'][$ligne['numero_manche']] = $ligne['score']; } } else { global $glob_debug; if ($glob_debug) { echo 'ERREUR SQL MANCHES'; } exit; } } $matches[$match['id_match']]['nbr_joueurs'] = $cpt; } else { global $glob_debug; if ($glob_debug) {
if (is_null($match['id_enfant1']) and is_null($match['id_enfant2'])) { $petite_finale = $match['id_match']; } else { $finale = $match['id_match']; } } $nbrmatch++; $sql2 = 'SELECT mte.id_equipe, e.nom, (SELECT SUM(ma.score) FROM manches_equipes AS ma WHERE ma.id_match=:idm AND ma.id_equipe=mte.id_equipe GROUP BY ma.id_equipe) AS score FROM matchs_equipes AS mte, equipes AS e WHERE mte.id_match=:idm AND e.id_equipes=mte.id_equipe'; $query2 = new Query($database, $sql2); $query2->bind(':idm', $match['id_match'], PDO::PARAM_INT); if ($query2->execute()) { $cpt = 1; foreach ($query2->getResult() as $team) { $matches[$match['id_match']][$cpt]['id'] = $team['id_equipe']; $matches[$match['id_match']][$cpt]['nom'] = $team['nom']; $matches[$match['id_match']][$cpt]['score'] = $team['score']; $cpt++; } } else { global $glob_debug; if ($glob_debug) { echo 'ERREUR SQL TEAMS'; } exit; } }
/** * Searches objects by text parameters * @param $classId Id of the class * @param $text Text to lookup in the objects * @param $fullTextSearch if true, the text is searched in all text fields and every coincidence is returned. * If false, it is only looked up in the title. */ function findByText($classId, $text, $fullTextSearch, $folderId = -1) { $objectQuery = new Query("Object"); $criteriaGroup = new CriteriaGroup(CriteriaGroup::getAndSeparator()); // Lookup by class... $criteria = new Criteria($objectQuery, "classID", $classId); $criteriaGroup->addCriterion($criteria); if ($folderId != -1 && $folderId != null) { // Lookup by folder... $objectFolderQuery =& $objectQuery->queryRelationedClass("ObjectFolder"); $folderCriteria = new Criteria($objectFolderQuery, "folderID", $folderId); $criteriaGroup->addCriterion($folderCriteria); } // ... and criterias sent if ($fullTextSearch) { // by fullTextIndex $criteria = new Criteria($objectQuery, "fullTextIndex", $text, Criteria::likeType()); $criteriaGroup->addCriterion($criteria); } else { // Issue a query to ObjectAttribute entity $objectAttributeQuery =& $objectQuery->queryRelationedClass("ObjectAttribute"); // Get the class $baseClassMapper = new BaseClassMapper(); $class = $baseClassMapper->get($classId); /* @var $class BaseClass */ // Get the fields that compose the title $titleClassAttributesArray = $class->getTitleClassAttributes(); // We need to query all title fields using the given value with OR (anyone can match) $criteriaGroupTitle = new CriteriaGroup(CriteriaGroup::getOrSeparator()); foreach ($titleClassAttributesArray as $titleClassAttribute) { // Must belong to the given class and LIKE the given title $criteriaGroupItem = new CriteriaGroup(); /* @var $titleClassAttribute ClassAttribute */ $criteriaGroupItem->addCriterion($criteria); $criteria = new Criteria($objectAttributeQuery, "classAttributeId", $titleClassAttribute->getId()); $criteriaGroupItem->addCriterion($criteria); $criteria = new Criteria($objectAttributeQuery, "value", $text, Criteria::likeType()); $criteriaGroupItem->addCriterion($criteria); $criteriaGroupTitle->addCriterion($criteriaGroupItem); } // Set the title criteria $criteriaGroup->addCriterion($criteriaGroupTitle); } $objectQuery->setCriterion($criteriaGroup); // Execute the query and map the results $objectMapper = new ObjectMapper(); $rv = $objectMapper->mapAll($objectQuery->execute()); return $rv; }
curl_setopt($ch, CURLOPT_URL, "http://192.168.4.152:82/cgi-win/tcgi.exe"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); //$curlPost = "title=%C8%FD%B9%FA%D1%DD%D2%E5&subject1=&subject2=&subject3=&author=&classfi=&cltype=690&publisher=&library=0&rectype=-1&fromyear=&toyear=&lang=0&maxrow=50&query=%BC%EC%CB%F7"; $curlPost = "title=" . $word . "&subject1=&subject2=&subject3=&author=&classfi=&cltype=690&publisher=&library=0&rectype=-1&fromyear=&toyear=&lang=0&maxrow=50&query=%BC%EC%CB%F7"; curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $output = curl_exec($ch); curl_close($ch); //$dom = new Query($output); //$results = $dom->execute('ol'); //foreach ($results as $result) { // $output = $result->ownerDocument->saveXML($result); //} $dom = new Query($output); $results = $dom->execute('li'); $rs = array(); //echo count($results); foreach ($results as $result) { //$href=$result->nodeValue; list($title2, $year, $classno) = explode(",", $result->nodeValue); list($title, $authors) = explode("/", $title2); //http://192.168.4.152:82/cgi-win/tcgid.exe?s66276r20wmysql $href = $result->getElementsByTagName('a')->item(0)->getAttribute('href'); $href = substr($href, strpos($href, '?') + 1); array_push($rs, array("title" => $title, "authors" => $authors, "year" => $year, "href" => $href, "classno" => $classno)); } header('Content-Encoding: plain'); echo json_encode($rs); //header("Content-type:text/html;charset=utf-8"); //echo $output;
} $groupes[$itGroupe]['teams'] = $teams; $heures = ''; if (is_array($teams)) { foreach ($teams as $team) { $sql = 'SELECT m.id_match,m.heure, SUM(me.score) as score, (SELECT mte2.id_equipe FROM matchs_equipes as mte2 WHERE mte2.id_match=m.id_match AND mte2.id_equipe<>:ide LIMIT 0,1) as team2 FROM (matchs_equipes as mte, matchs as m) LEFT JOIN (manches_equipes as me) ON (me.id_match=m.id_match AND me.id_equipe=:ide) WHERE m.id_groupe=:idg AND mte.id_match=m.id_match AND mte.id_equipe=:ide GROUP BY m.id_match'; $query = new Query($database, $sql); $query->bind(':idg', $groupe['id_groupe'], PDO::PARAM_INT); $query->bind(':ide', $team['id'], PDO::PARAM_INT); if ($query->execute()) { foreach ($query->getResult() as $ligne) { if (!is_null($ligne['score'])) { $scores[$team['id']][$ligne['team2']]['score'] = $ligne['score']; $scores[$team['id']][$ligne['team2']]['id_match'] = $ligne['id_match']; } $heures[$team['id']][$ligne['team2']] = $ligne['heure']; } } else { global $glob_debug; if ($glob_debug) { echo 'ERREUR SQL SCORES TEAM 1'; } exit; } }
/** * Executes the query * * @param {assoc} $paramValues */ public function execute($paramValues = null) { parent::execute($paramValues); $data = $this->base->select($this->paramValues); $this->bindChildren($data); return $data; }
<?php // Created on Nov 14 2013 by Ian Santagata // Version 1.0 // Checks to see if the game has been won/tied and if the game is over // // Returns 1 if game is over and returns 0 if game is not over include "../lib/Query.php"; // Pull all of the coordinate and username data from the table $q = new Query("SELECT * FROM gstate"); $q->execute(); $spot0 = $q->getRow(0); $spot1 = $q->getRow(1); $spot2 = $q->getRow(2); $spot3 = $q->getRow(3); $spot4 = $q->getRow(4); $spot5 = $q->getRow(5); $spot6 = $q->getRow(6); $spot7 = $q->getRow(7); $spot8 = $q->getRow(8); // Test for winning conditions based on upper left spot switch ($spot0[1]) { case $username: // If upper three spots owned by same user switch ($spot1[1]) { case $username: switch ($spot2[1]) { case $username: return 1; } break;
} exit; } else { $nbr_lb2 = $query->getResult()[0]; $nbr_lb2 = $nbr_lb2['nbr']; } // Setting the loser brackets $nbr_lb2 = 0; $nbr_lb3 = 0; //SQL Query to count the number of matchs for a tournament and a double looser bracket $sql = 'SELECT COUNT(*) AS nbr FROM matchs WHERE id_groupe IS NULL AND id_tournoi=:idt AND looser_bracket=3'; $query = new Query($database, $sql); $query->bind(':idt', $id_tournoi, PDO::PARAM_INT); if (!$query->execute()) { global $glob_debug; if ($glob_debug) { echo 'ERREUR - SQL COUNT LB3'; } exit; } else { $nbr_lb3 = $query->getResult()[0]; $nbr_lb3 = $nbr_lb3['nbr']; } // Select the Pool or Round mode $tournoi = $database->getTournament($id_tournoi); //if( $tournoi['joueurParTeam'] > 1) if ($id_tournoi != 3) { include_once DOCUMENT_ROOT . '/modules/tournoisPools.php'; } else {
function view_query($qid) { $query = new Query($qid); $query->execute(); }
<?php session_start(); require_once '../common/var.conf.php'; require_once DOCUMENT_ROOT . '/common/utils.php'; require_once DOCUMENT_ROOT . '/class/Smarty_HEHLan.class.php'; require_once DOCUMENT_ROOT . '/class/Database.class.php'; require_once DOCUMENT_ROOT . '/class/Auth.class.php'; require_once DOCUMENT_ROOT . '/class/Query.class.php'; $connected = false; $allowed = false; $chatIsActive = false; $database = new Database(); $smarty = new Smarty_HEHLan(); $connected = Auth::isLogged(); $allowed = Auth::isAllowed(3); if (!$connected && !$allowed) { header('Location: ../index.php'); } $sql = 'SELECT * FROM downloads ORDER BY published_date DESC'; $query = new Query($database, $sql); $query->execute(); $downloads = $query->getResult(); // send to the template $smarty->assign('con', $connected); $smarty->assign('downloads', $downloads); $smarty->display(DOCUMENT_ROOT . '/view/templates/admin/downloads.tpl');
/** * Executes the current SQL query. * * $values is an array of values to substitute. The syntax for denoting * bind_values in the SQL query is a double-questionmark (??). * * Returns the new SQL query. Note: does not modify the actual $sql property. * * @access public * @param array $values * @return resource * */ function execute() { // call bind_values $this->bind_values(func_get_args()); if (parent::execute()) { // if parent::execute () returns true, then we're using the cached copy, // so no need to query the database return true; } // query the database $this->result = @pg_query($this->connection, $this->tmp_sql); return $this->result; }