本文整理汇总了PHP中query::select方法的典型用法代码示例。如果您正苦于以下问题:PHP query::select方法的具体用法?PHP query::select怎么用?PHP query::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类query
的用法示例。
在下文中一共展示了query::select方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNice
function getNice()
{
if ($this->config['source']['type'] == 'table' && isset($this->config['source']['name'])) {
global $thinkedit;
$config = new config();
//$table = $thinkedit->newTable($this->config['source']['name']);
//
//$source->filter('id', '=', $this->getRaw());
$source_table = $this->config['source']['name'];
$title_fields = $config->getTitleFields($source_table);
require_once 'query.class.php';
$query = new query();
$query->addTable($this->config['source']['name']);
$query->addWhere('id', '=', $this->getRaw());
$results = $query->select();
if (count($results) > 0) {
foreach ($config->getTitleFields($source_table) as $field) {
$out .= $results[0][$field] . ' ';
}
return $out;
} else {
return $this->getRaw();
}
} else {
return $this->getRaw();
}
}
示例2: dispatcher
function dispatcher ($db, $pagename)
{
# Same with database object
$this->db = $db;
# Make the pagename safe and local.
$this->dPageName = janitor::cleanData($pagename);
# Get information about the current page from the database
$query = new query();
$query->select(
array (
'qbPages.*' ,
'qbSections.name' => 'sName' ,
'qbSections.title' => 'sTitle' ,
'qbSections.defaultpage' => 'sDefaultPage' ,
'qbSections.cssId' => 'sCssId'
))->from('qbPages')->joinLeft('qbSections', 'qbPages.qbSectionId', 'id')->where('qbPages.name',
$this->dPageName);
$result = $this->db->query($query);
# If there aren't any, show a 404 page.
if ($this->db->numRows($result) < 1)
{
$query = new query();
$query->select()->from('qbPages')->where('name', '404');
$result = $this->db->query($query);
header("HTTP/1.1 404 Not Found");
}
# Put data about page into a local array
$this->dPage = $this->db->assoc($result);
# Start an authority check to discern if its okay for the current user to be on this page
$this->dAuth = new authorityCheck($_SESSION['userdata']['accessLevel'], $this->dPage['accessLevel']);
if (! $this->dAuth->isAuthed())
{
# If they aren't, show a 403
$query = new $query();
$query->select()->from('qbPages')->where('name', '403');
$result = $this->db->query($query);
header("HTTP/1.1 403 Forbidden");
$this->dPage = $this->db->assoc($result);
}
$this->dPage['pageVars'] = janitor::pageVars($this->dPage['pageVars']);
$this->dInclude = $this->dispatcherPath($this->dPage['qbDispatcher']);
}
示例3: checkCookie
public function checkCookie ($cookie)
{
$user = janitor::cleanData($cookie['user'], 'sql');
$query = new query();
$query->select()->from('userUsers')->joinLeft('userGroups', 'userUsers.group', 'id')->where('username', $user)->limit(
'1');
$result = $this->sDb->query($query);
if ($this->sDb->numRows($result) > 0)
{
$data = $this->sDb->assoc($result);
if ($cookie['hash'] == md5(md5($data['email']) . $data['email']))
{
$query = new query();
$this->user = $user;
$this->userData = $data;
$this->setCookie($user, $_SESSION['userdata']['email']);
$this->setSession();
}
}
}
示例4: consultaAsistentes
function consultaAsistentes()
{
$query = new query();
$asistentes = $query->select("id, nombre, ap_pat, ap_mat, edad, sexo, telefono_casa, email, idKoinonia, idMunicipio", "asistente");
if ($asistentes) {
echo '<div class="tab-content">
<table id="example" class="display table table-striped" cellspacing="0" width="100%">
<thead>
<tr>
<th>Nombre</th>
<th>Edad</th>
<th>Teléfono de Emergencia</th>
<th>Municipio</th>
<th>Estado</th>
<th>Koinonia</th>
<th>Email</th>
<th>Editar</th>
</tr>
</thead>
<tbody>';
foreach ($asistentes as $asistente) {
$municipio = $query->select("*", "municipio", "id={$asistente->idMunicipio}", "", "arr");
$estado = $query->select("*", "estado", "id={$municipio['2']}", "", "arr");
$koinonia = $query->select("*", "koinonia", "id={$asistente->idKoinonia}", "", "arr");
echo '<tr>
<td>' . utf8_encode($asistente->nombre) . ' ' . utf8_encode($asistente->ap_pat) . ' ' . utf8_encode($asistente->ap_mat) . '</td>
<td>' . $asistente->edad . '</td>
<td>' . $asistente->telefono_casa . '</td>
<td>' . utf8_encode($municipio[1]) . '</td>
<td>' . utf8_encode($estado[1]) . '</td>
<td>' . utf8_encode($koinonia[1]) . '</td>
<td>' . $asistente->email . '</td>
<td><a href="editarAsistente.php?id=' . $asistente->id . '" ><span class=\'glyphicon glyphicon-pencil\' ></span> Editar</a></td></tr>';
}
echo '</tbody>
</table></div>';
} else {
echo "<div class='alert wet-asphalt' role='alert'>No se encontraron asistentes.</div>";
}
}
示例5: outerJoin
/**
* Performs an OUTER JOIN
*
* Although OUTER JOIN doesn't exists in MySQL, this method allow to simulate it.
* Because of that, this method must be called instead of the FROM method.
* You have to provide both tables plus "ON" fields.
*
* You can use only one outerJoin in a query, and must not call
* query::from or query::on methods.
*
* This method is based on UNION, LEFT JOIN and RIGHT JOIN.
*
* @access public
* @param mixed $table name of main table
* @param mixed $join name of table to join
* @param mixed $on1 field of main table to filter on
* @param mixed $on2 field of join table to filter on
* @return query $this for chaining
*/
public function outerJoin($table, $join, $on1, $on2)
{
// sub-join 2 (right part of outer join)
$subrequest2 = new query($this->cache);
$subrequest2->select()->from($table)->rightJoin($join)->on($on1, $on2)->where($on1, 'IS NULL', false);
// sub-join 1 (left part of outer join)
$subRequest1 = new query($this->cache);
$subRequest1->select()->from($table)->leftJoin($join)->on($on1, $on2)->addString(' UNION ALL (' . $subrequest2->getRequest() . ') ');
$this->content['join'] = true;
$this->table['join'][] = $join;
// small workaround
return $this->from($subRequest1);
}
示例6: query
# eaten by robots by then anyway so it doesn't matter.
$name = $safeGet['name'];
$query = new query();
$query->select('id')->from('newsArticles')->where('name', $name)->limit('1');
$result = $this->db->query($query);
$row = $this->db->assoc($result);
$article = metaclass::load('newsArticle', $row['id']);
$this->dOutput['news']['header'] = $article->getProperty('title');
$this->dOutput['news']['content'] = $article->getProperty('text');
} else
{
$query = new query();
$query->select(array (
'id' ,
'name' ,
'date' ,
'title' ,
'textshort'
))->from('newsArticles')->order('date', 'desc');
$result = $this->db->query($query);
$i = 0;
while ($row = $this->db->assoc($result))
{
$this->dOutput['news']['listing'] = true;
$row['date'] = explode('-', $row['date']);
$row['date'][0] = substr($row['date'][0], 2, 2);
$row['date'] = implode('/', array_reverse($row['date']));
$row['dateLink'] = $row['name'];
$this->dOutput['news']['articles'][$i] = $row;
$i ++;
}
示例7: select
public function select($what = null)
{
$q = new query($this, $this->_className);
if (null !== $what) {
$q->select($what);
}
return $q;
}
示例8: query
$query = new query();
$query->select('id')->from('articles')->where('name', $name)->limit('1');
$result = $this->db->query($query);
$row = $this->db->assoc($result);
$article = metaclass::load('article', $row['id']);
$this->dOutput['article']['header'] = $article->getProperty('title');
$this->dOutput['article']['date'] = janitor::formatMysqlDateTime($article->getProperty('date'), 'l jS F, Y');
$this->dOutput['article']['fulltext'] = $md->process($article->getProperty('fulltext'));
$this->dOutput['pageTitle'] = $article->getProperty('title');
} else
{
$query = new query();
$query->select(array (
'id' ,
'name' ,
'date' ,
'title' ,
'preview'
))->from('articles')->order('date', 'desc');
$result = $this->db->query($query);
$i = 0;
while ($row = $this->db->assoc($result))
{
$this->dOutput['articles']['listing'] = true;
$row['dateLink'] = $row['name'];
$this->dOutput['articles']['articles'][$i] = $row;
$this->dOutput['articles']['articles'][$i]['preview'] = $md->process($row['preview']);
$this->dOutput['articles']['articles'][$i]['date'] = janitor::formatMysqlDateTime($row['date'], 'jS M, Y');
$i ++;
}
}
示例9: query
if ($_POST["model"] != null && $_POST["color"] != null && $_POST["size"] != null) {
$modelid = $_POST["model"];
$colorid = $_POST["color"];
$sizeid = $_POST["size"];
$sentencia = "s.status = 0 or s.status = 1 or s.status = 3 ";
if ($modelid != 0) {
$sentencia = $sentencia . "and m.modelid = {$modelid} ";
}
if ($colorid != 0) {
$sentencia = $sentencia . "and c.colorid = {$colorid} ";
}
if ($sizeid != 0) {
$sentencia = $sentencia . "and z.sizesid = {$sizeid} ";
}
$query = new query();
$stocks = $query->select("s.stockid as id, shoe.price as price, m.title as model, c.title as color, z.size as size, b.name as branch_name, b.address as branch_address, b.branchid, s.status", "detail_stock s\n\t\t\t\t\t\tjoin shoe on s.shoeid = shoe.shoeid\n\t\t\t\t\t\tjoin model m on m.modelid = shoe.modelid\n\t\t\t\t\t\tjoin sizes z on z.sizesid = shoe.sizesid\n\t\t\t\t\t\tjoin color c on c.colorid = shoe.colorid\n\t\t\t\t\t\tjoin branch b on b.branchid = s.branchid", $sentencia . " order by s.shoeid", "", "obj");
if (count($stocks) > 0) {
$result = "";
foreach ($stocks as $stock) {
$transacciones = $query->select("stockid", "transition_shoe_log", "stockid = {$stock->id}", "and employeeid_receiber is null", "obj");
$result = $result . '<tr>
<td>' . $stock->model . '</td>
<td>' . $stock->size . '</td>
<td>' . $stock->color . '</td>
<td class="viewDiscount">' . $stock->price . '</td>
<td><code>' . $stock->branch_name . '</code> <i class="icon-home icon-small"></i> ' . $stock->branch_address . '</td>';
if ($stock->status == 1) {
$result = $result . '<td><i class="icon-frown icon-small"></i> No disponible</td>';
$result = $result . '<td><i class="icon-frown icon-small"></i> No disponible</td>';
} else {
if (count($transacciones) > 0) {
示例10: option
/**
*
* Description : Retourne ou modifie les paramètres personnalisés de l'utilisateur.
* Paramètres :
* [$key] - (string) : Nom de l'option
* [$value] - (string) : Valeur de l'option.
* Retour :
* - (bool) "true" : l'option a été créée
* - (bool) "false" : l'option n'existe pas
* - (array) : Tableau associatif de toutes les fonctions si la méthode est appelée sans aucun paramètre
* - (string) : Valeur l'option dans la BDD si le paramètre $value n'est pas renseignée lors de l'appel de la méthode.
*/
public function option($key = false, $value = false)
{
if (count($this->option) == 0) {
$req = new query();
$req->select('key', 'value')->from("user_option")->where('owner', '=', $this->get('id'))->exec("ALL");
while ($result = $req->next()) {
$this->option[$req->get("key")] = $req->get("value");
}
}
if (!$key) {
return $this->option;
} elseif (!$value) {
if (isset($this->option[$key])) {
return $this->option[$key];
} else {
return false;
}
} else {
if (!isset($this->option[$key])) {
$this->create[] = $key;
$this->option[$key] = $value;
return true;
} elseif ($this->option[$key] != $value) {
$this->change[] = $key;
$this->option[$key] = $value;
return true;
} else {
return false;
}
}
}
示例11: getItems
/**
* Get a list of objects from the database.
*
* @todo Make this way way more flexible.
* @param string $table The table to query.
* @param array $fields Specific fields to retrieve.
* @return array Array of row data.
*/
public function getItems ($table, $fields = false, $order = false)
{
$query = new query();
$query->select($fields)->from($table)->order($order);
$result = metaclass::$db->query($query);
while ($row = metaclass::$db->assoc($result))
{
$return[] = $row;
}
return $return;
}
示例12: formField
function formField ($name, $title, $value = null, $linkfield, $properties)
{
$cvs = metaclass::getClassVars($properties['requirements']['real']);
if (metaclass::$db->tableExists($cvs['table']))
{
$query = new query();
$query->select(array (
'id' ,
'title'
))->from($cvs['table']);
$result = metaclass::$db->query($query);
$return .= '<label for="' . $name . '">
' . $title . '
</label><br/>
<select id="' . $name . '" name="' . $name . '">';
while ($row = metaclass::$db->assoc($result))
{
$return .= '<option value="' . $row['id'] . '"' . ($row['id'] == $value ? ' selected' : null) . '>' .
$row['title'] . '</option>';
}
$return .= '</select>
<br/>';
} else
{
$return .= '<label for="' . $name . '">
' . $title . '
</label><br/>';
$return .= '<p class="error">' . text::get('form/foreignTableNotExist', $cvs['title']) . '</p>';
}
return $return;
}