本文整理汇总了PHP中DatabaseConnection::select方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::select方法的具体用法?PHP DatabaseConnection::select怎么用?PHP DatabaseConnection::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::select方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
/**
* {@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;
}
示例2: loadWithConditions
/**
* {@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;
}
示例3: getStudentIds
function getStudentIds()
{
$db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
$sql = "SELECT id FROM students";
$string = array();
$res = $db->select($sql, $string, false, '');
return $res;
}
示例4: addNewStudent
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;
}
示例5: addNewStudent
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;
}
示例6: getSubjectIds
public static function getSubjectIds()
{
$db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
$sql = "SELECT id FROM subjects";
$string = array();
return $db->select($sql, $string, false, '');
}
示例7: getMisses
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'];
}
示例8: pathHasMatchingAlias
/**
* {@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();
}
示例9: getSubject
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'];
}
示例10: select
public function select($table, $alias = NULL, array $options = array())
{
return $this->connection->select($table, $alias, $options);
}
示例11: select
/**
* @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);
}