public function getEnrollmentForm($uid, $tid, $eid, $mem) { $ret = array('personal' => array(), 'tour' => array(), 'enroll' => array(), 'members' => $mem); $p = parent::prepare("SELECT * FROM users " . "INNER JOIN students ON id=stu_user_id " . "AND users.id=" . $uid); $p->execute(); $ret['personal'] = $p->fetchAll(); $q = new Query(); $q->where = array('tou_id' => $tid); $rest = $q->inner_join('tours', 'paymen_shema', array('tou_id', 'psc_tour_id')); $ret['tour'] = $rest[0]; $q->table = 'enroll_full'; $q->where = array('enf_id' => $eid); $rese = $q->read(); $ret['enroll'] = $rese[0]; return $ret; }
/** * @param $input * @param $expected * @dataProvider inputProvider */ public function testRead($input, $expected) { $pdo = $this->createPDO(); $pdoStatement = $this->createPDOStatement(); $connection = $this->createConnection($pdo); $statement = 'some sql statement'; $returnInfo = ['info in an array']; $pdo->expects($this->once())->method('prepare')->with($this->equalTo($statement))->will($this->returnValue($pdoStatement)); $statementCount = 0; foreach ($input as $field => $value) { $pdoStatement->expects($this->at($statementCount++))->method('bindValue')->with($this->equalTo(":{$field}"), $this->equalTo($value), $this->equalTo($expected[$field])); } $pdoStatement->expects($this->once())->method('execute'); $pdoStatement->expects($this->once())->method('fetchAll')->will($this->returnValue($returnInfo)); $query = new Query($connection); $this->assertEquals($returnInfo, $query->read($statement, $input)); }
function selection($table, $where = null, $order = null, $ascdesc = null, $limit = null, $between = null) { $q = new Query(); $q->table = $table; if (null !== $where) { $q->where = $where; } if (null !== $order) { $q->order = $order; } if (null !== $ascdesc) { $q->ascdesc = $ascdesc; } if (null !== $limit) { $q->limit = $limit; } if (null !== $between) { $q->between = $between; } $res = $q->read(); return $res; }
public function logAuth($post) { $q = new Query(); $q->table = 'users'; $q->where = array('username' => $post['username'], 'password' => md5($post['password'])); $res = $q->read(); if (count($res) > 0) { session_start(); session_regenerate_id(); $_SESSION['USER_ID'] = $res[0]['id']; $_SESSION['USER_ROLE'] = $res[0]['role']; if ($res[0]['role'] === 'U') { header('Location: /myprofile'); } elseif ($res[0]['role'] === 'G') { header('Location: /leaders'); } else { header('Location: /admin-main'); } } else { header('Location: /home/e'); } }
public function read($input) { $xfer = 0; $fname = null; $ftype = 0; $fid = 0; $xfer += $input->readStructBegin($fname); while (true) { $xfer += $input->readFieldBegin($fname, $ftype, $fid); if ($ftype == TType::STOP) { break; } switch ($fid) { case 1: if ($ftype == TType::LST) { $this->queries = array(); $_size114 = 0; $_etype117 = 0; $xfer += $input->readListBegin($_etype117, $_size114); for ($_i118 = 0; $_i118 < $_size114; ++$_i118) { $elem119 = null; $elem119 = new \Query(); $xfer += $elem119->read($input); $this->queries[] = $elem119; } $xfer += $input->readListEnd(); } else { $xfer += $input->skip($ftype); } break; case 2: if ($ftype == TType::BOOL) { $xfer += $input->readBool($this->done); } else { $xfer += $input->skip($ftype); } break; case 3: if ($ftype == TType::BOOL) { $xfer += $input->readBool($this->started); } else { $xfer += $input->skip($ftype); } break; default: $xfer += $input->skip($ftype); break; } $xfer += $input->readFieldEnd(); } $xfer += $input->readStructEnd(); return $xfer; }
addButton('btn btn-success', 'Submit', 'col-sm-offset-2 col-sm-4', 'Sign Up'); ?> </fieldset> </form> <?php require_once 'Status.php'; require_once 'database.php'; $q = new Status($db); $q->viewStatus('dvd', 'available', 'Return'); ?> <?php require_once "Query.php"; $crud_book = new Query(7, 'dvd', 'item_no,title,genre,description,price,rental_period,status'); $crud_book->mysqlConnect('localhost', 'root', '', 'video_rental'); $crud_book->create(); echo "<hr/>"; $crud_book->read(); echo "<hr/>"; $crud_book->update(); echo "<hr/>"; $crud_book->delete(); echo "<hr/>"; ?> </div> </div> </div> </body> </html>
/** * Read a file * * @access public * * @param $path file path * @param $fh file descriptor * @param $offset offset to read from * @param $bufLen max length to read * @param $buf the read contents */ function read($path, $fh, $offset, $bufLen, &$buf) { $buffer = ""; Log::in("READ"); Log::output("Path {$path}"); Log::output("FH {$fh}"); Log::output("Offset {$offset}"); Log::output("Length {$bufLen}"); /* Check for passthru */ if (PassThru::check($path)) { $ret = PassThru::read($path, $offset, $bufLen, $buf); } else { $pi = Query::pathInfo($path); /* Get the content id from the path, or fh */ $ret = Query::fillContentId($pi, $fh); if ($ret != 0) { Log::out("READ fill content failed"); return $ret; } /* Assign buf directly */ $ret = Query::read($pi, $buffer, $bufLen, $offset); Log::output("READ assigning buffer"); $buf = $buffer; } Log::out("READ"); return $ret; }