Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function find($string, $prefix = true, $limit = 20)
 {
     if ($prefix) {
         $escaped = db_like($string) . '%';
     } else {
         $escaped = '%' . db_like($string) . '%';
     }
     $map = $this->db->select('node', 'n')->fields('n', ['nid', 'title'])->condition('n.type', $this->bundle)->condition('n.title', $escaped, 'LIKE')->orderBy('n.title')->range(0, $limit)->execute()->fetchAllKeyed();
     $ret = [];
     foreach ($map as $id => $title) {
         $ret[] = new EntityFinderResult('node', $id, $title, $this->getLabel());
     }
     return $ret;
 }
 /**
  * {@inheritdoc}
  */
 public function loadWithConditions($conditions)
 {
     $q = $this->db->select('umenu', 'um')->fields('um');
     foreach ($conditions as $key => $value) {
         $q->condition('um.' . $key, $value);
     }
     $r = $q->execute();
     $r->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, Menu::class);
     $ret = [];
     while ($menu = $r->fetch()) {
         $ret[$menu->getName()] = $menu;
     }
     return $ret;
 }
Ejemplo n.º 3
0
function getStudentIds()
{
    $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
    $sql = "SELECT id FROM students";
    $string = array();
    $res = $db->select($sql, $string, false, '');
    return $res;
}
Ejemplo n.º 4
0
function addNewStudent($login_code, $name, $birth, $pass, $email, $pn, $city, $subj)
{
    $sql = "INSERT INTO teachers VALUES ('', ?, ?, ?, ?, ?, ?, ?)";
    $string = array($login_code, $name, $birth, $pass, $email, $pn, $city);
    $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
    $db->queryWithoutResult($sql, $string, true, "sssssss");
    $sql = 'SELECT id FROM teachers WHERE code = ?';
    $string = array($login_code);
    $res = $db->select($sql, $string, true, 's');
    $sql = "INSERT INTO teacher_subj VALUES (?,?)";
    $string = array($res[0]['id'], $subj);
    $db->queryWithoutResult($sql, $string, true, "is");
    return true;
}
Ejemplo n.º 5
0
function addNewStudent($login_code, $name, $birth, $resi, $pass, $email, $ppn, $year, $class, $s_hostel, $allowance)
{
    $sql = "INSERT INTO students VALUES ('', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
    $string = array($login_code, $name, $birth, $resi, $s_hostel, $allowance, $pass, $email, $ppn, $year, strtolower($class));
    $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
    $db->queryWithoutResult($sql, $string, true, "ssssiisssis");
    $sql = 'SELECT id FROM students WHERE login_code = ?';
    $string = array($login_code);
    $res = $db->select($sql, $string, true, 's');
    $zero = mt_rand(0, 18);
    $sql = "INSERT INTO misses VALUES (?,?)";
    $string = array($res[0]['id'], $zero);
    $db->queryWithoutResult($sql, $string, true, "ii");
    return true;
}
Ejemplo n.º 6
0
 public static function getSubjectIds()
 {
     $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
     $sql = "SELECT id FROM subjects";
     $string = array();
     return $db->select($sql, $string, false, '');
 }
Ejemplo n.º 7
0
 public function getMisses()
 {
     $id = $this->getId();
     $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
     $sql = "SELECT number FROM misses WHERE id = ?";
     $string = array($id);
     $res = $db->select($sql, $string, true, 'i');
     return $res[0]['number'];
 }
 /**
  * {@inheritdoc}
  */
 public function pathHasMatchingAlias($initial_substring)
 {
     $query = $this->db->select('url_alias', 'u');
     $query->addExpression(1);
     return (bool) $query->condition('u.source', $this->db->escapeLike($initial_substring) . '%', 'LIKE')->range(0, 1)->execute()->fetchField();
 }
Ejemplo n.º 9
0
 public function getSubject($id)
 {
     $db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
     $sql = "SELECT name FROM subjects WHERE id = ?";
     $string = array($id);
     $res = $db->select($sql, $string, true, 'i');
     return $res[0]['name'];
 }
Ejemplo n.º 10
0
 public function select($table, $alias = NULL, array $options = array())
 {
     return $this->connection->select($table, $alias, $options);
 }
Ejemplo n.º 11
0
 /**
  * @see DatabaseConnection::select
  */
 public function select($columns = '*', $where = '', $whereArgs = array(), $orderBy = null, $limit = null)
 {
     return $this->dbc->select($this->tblname, $columns, $where, $whereArgs, $orderBy, $limit);
 }