public function fetch_data($UID = NULL) { $param = [$UID == NULL ? $this->UID : $UID]; //This is an array containing the UID parameter for the query, if the function argument is null it uses the object's uid $query = "SELECT * FROM notes WHERE UID = ?"; $handle = new Query($this->pdo, $query); $handle->exec($param); if (!($result = $handle->fetch())) { return false; } $this->_copy($result); return true; }
/** * Returns the next row of data from the current query, always in the * form of an object, with each column as its properties. * * MISSING: ($offset, $limit) optional parameters * * @access public * @return object * */ function fetch() { if ($this->result) { switch ($this->cache_action) { case 0: //print_r ($this); return @pg_fetch_object($this->result); case 1: //print_r ($this); return parent::fetch(); case 2: //print_r ($this); $this->_row = @pg_fetch_object($this->result); return parent::fetch(); case 3: //print_r ($this); $this->_row = @pg_fetch_object($this->result); return parent::fetch(); } } else { //print_r ($this); return 0; } }
/** * Returns the next row of data from the current query, always in the * form of an object, with each column as its properties. * * @access public * @return object * */ function fetch($offset = 0, $limit = 0) { if ($this->result) { if ($limit > 0) { $res = array(); $c = 0; while ($row = $this->fetch()) { if ($c < $offset) { $c++; continue; } elseif ($c >= $offset + $limit) { break; } $res[] = $row; $c++; } return $res; } switch ($this->cache_action) { case 0: //print_r ($this); return @$this->_fetchModeFunctions[db_fetch_mode()]($this->result); case 1: //print_r ($this); return parent::fetch(); case 2: //print_r ($this); $this->_row = @$this->_fetchModeFunctions[db_fetch_mode()]($this->result); return parent::fetch(); case 3: //print_r ($this); $this->_row = @$this->_fetchModeFunctions[db_fetch_mode()]($this->result); return parent::fetch(); } } else { //print_r ($this); return 0; } }
/** * Gets the parent asset id for the record * * @return int * @since 2.0.0 */ private function getAssetParentId() { $assetId = null; // Build the query to get the asset id for the parent category $query = new Query(); $query->select('id')->from('#__assets')->whereEquals('name', 'com_' . $this->model->getNamespace()); if ($results = $query->fetch()) { $result = $results[0]; $assetId = (int) $result->id; } return $assetId ? $assetId : $this->getRootId(); }
function existe_manche_de_finale($database, $idt, $jpt, $lb) { if ($jpt > 1) { //SQL query to count ??? $sql_func = 'SELECT COUNT(*) as nbr FROM manches_equipes as me, matchs as m WHERE m.id_tournoi=:idt AND m.id_groupe IS NULL AND me.id_match=m.id_match AND m.looser_bracket=:lb'; } else { //SQL query to count ??? $sql_func = 'SELECT COUNT(*) as nbr FROM manches_joueurs as mj, matchs as m WHERE m.id_tournoi=:idt AND m.id_groupe IS NULL AND mj.id_match=m.id_match AND m.looser_bracket=:lb'; } $query_func = new Query($databse, $sql_func); $query_func->bind(':idt', $idt, PDO::PARAM_INT); $query_func->bind(':lb', $lb, PDO::PARAM_INT); if ($query_func->execute()) { $nbr = $query_func->fetch(PDO::FETCH_ASSOC); } else { global $glob_debug; if ($glob_debug) { echo 'ERREUR - EXISTE MANCHE GROUPE TEAM SQL'; } exit; } $nbr = $nbr['nbr']; if ($nbr == 0) { return false; } else { return true; } }
<?php /* * Testing a few simple queries to see if the Query wrapper class works properly */ include "../src/core.php"; $query = new Query($pdo_link, "SELECT 2+2"); print_r($query->exec() == true); $query->query = "CREATE TEMPORARY TABLE potatos (ID int PRIMARY KEY AUTO_INCREMENT, name varchar(20))"; print_r($query->exec() == true); $testing = ['Juana', 'Maria', 'Pablo']; $query->query = "INSERT INTO potatos (name) VALUES (?)"; foreach ($testing as $name) { print_r($query->exec([$name]) == true); } $query->query = "SELECT * FROM potatos"; print_r($query->exec() == true); while ($row = $query->fetch()) { print_r(is_array($row) == true); } /*Output should look like this: 111111111*/
Route::get('bookz/(:num)', function ($id) use($posts_page) { $Q = new Query('bookz_record'); $Q->where('id', '=', $id); if (!user_authed()) { $Q->where('is_published', '=', 1); } if (!($record = $Q->fetch())) { return Response::create(new Template('404'), 404); } if (!empty($record->id_parent)) { $QP = new Query('bookz_record'); $QP->where('id', '=', $record->id_parent); if (!user_authed()) { $QP->where('is_published', '=', 1); } $record->parent = $QP->fetch(); } $QCh = new Query('bookz_record'); $QCh->where('id_parent', '=', $record->id); if (!user_authed()) { $QCh->where('is_published', '=', 1); } $QCh->sort('ordkey', 'ASC'); $QCh->sort('title', 'ASC'); $record->child = $QCh->get(); $posts_page->title = $record->title; Registry::set('page', $posts_page); Registry::set('record', $record); return new Template('bookz_record'); }); /**