本文整理汇总了PHP中Query类的典型用法代码示例。如果您正苦于以下问题:PHP Query类的具体用法?PHP Query怎么用?PHP Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Query类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sort
/**
* Data retreival
*/
public function sort(array $fields = array())
{
$fields_query = new Query($fields, $this->collection);
$fields_query->compress();
$this->native->sort($fields_query->compressed);
return $this;
}
开发者ID:marcqualie,项目名称:mongominify,代码行数:10,代码来源:Cursor.php
示例2: updateDate
function updateDate($catalogue_id, $msgid)
{
$q = new Query();
$q->sql("UPDATE {messages} SET updated_at = NOW() WHERE msgid=? AND catalogue_id=?", $msgid, $catalogue_id)->execute();
//var_dump($catalogue_id);
//echo "true";
}
开发者ID:siran,项目名称:simplepo,代码行数:7,代码来源:message_service.php
示例3: save
/**
* Save model data.
* If model is new PK is null - we generate INSERT SQL request.
* If model data already exists in DB, PK > 0 - we generate UPDATE request.
* Method return true if model data saved successfully. False if error.
*/
public function save($validate = true)
{
if ($validate === true && $this->validate() === false) {
return false;
}
$columns = $this->getClearColumns();
$values = array();
foreach ($columns as $column) {
$values[] = $this->{$column};
}
$keyPosition = array_search($this->pkColumnName(), $columns);
array_splice($columns, $keyPosition, 1);
array_splice($values, $keyPosition, 1);
if ((int) $this->{$this->pkColumnName()} > 0) {
$query = new Query("update");
$query->addTable($this->tableName());
foreach ($columns as $key => $column) {
$query->addField($column, $values[$key]);
}
$query->where->add($this->pkColumnName() . " = " . $this->{$this->pkColumnName()});
$result = $query->exec();
} else {
$query = new Query("insert");
$query->addTable($this->tableName());
foreach ($columns as $key => $column) {
$query->addField($column, $values[$key]);
}
$result = $query->exec();
$this->ADDRESSID = $query->last_insert_id();
}
return $result;
}
开发者ID:zahar-g,项目名称:small_mvc_frmwrk,代码行数:38,代码来源:Model.php
示例4: filterQuery
/**
* Filters a query object
*
* @param Query $query
* @param Eloquent $model
*
* @return void
*/
public function filterQuery(&$query, $model)
{
//if the field is
if ($this->value !== '') {
$query->where($model->table() . '.' . $this->field, '=', $this->value);
}
}
开发者ID:ajb,项目名称:rfpez,代码行数:15,代码来源:Bool.php
示例5: testExecuteQueryFailed
public function testExecuteQueryFailed()
{
self::$functions->expects($this->once())->method('ldap_search')->with($this->equalTo('my_ldap_resource'), $this->equalTo('ou=People,dc=kanboard,dc=local'), $this->equalTo('uid=my_user'), $this->equalTo(array('displayname')))->will($this->returnValue(false));
$query = new Query();
$query->execute('my_ldap_resource', 'ou=People,dc=kanboard,dc=local', 'uid=my_user', array('displayname'));
$this->assertFalse($query->hasResult());
}
开发者ID:Folcky,项目名称:kanboard,代码行数:7,代码来源:QueryTest.php
示例6: matchRelationship
/**
* Add clause to match the relationship we want to delete
*
* @param IdentityInterface $identity
* @param $object $entity
* @param Query $query
*
* @return Query
*/
private function matchRelationship(IdentityInterface $identity, $entity, Query $query) : Query
{
$meta = $this->metadatas->get(get_class($entity));
$name = $this->name->sprintf(md5($identity->value()));
$this->variables = $this->variables->add((string) $name);
return $query->match()->linkedTo()->through((string) $meta->type(), (string) $name)->withProperty($meta->identity()->property(), (string) $name->prepend('{')->append('_identity}'))->withParameter((string) $name->append('_identity'), $identity->value());
}
开发者ID:innmind,项目名称:neo4j-onm,代码行数:16,代码来源:RemovePersister.php
示例7: Query
/**
* Gets the classes whose objects the user can execute certain action
*
* @param $action object - The action that the user should be allowed to do
* @param $user User - The user that holds de permissions
* @return Array - an array of class objects
*/
function &findByPermission($action, $user)
{
$classQuery = new Query("Class");
// Navigate relationships
$folderClassQuery =& $classQuery->queryRelationedClass("FolderClass");
$permissionQuery =& $folderClassQuery->queryRelationedClass("Permission");
$actionQuery =& $permissionQuery->queryRelationedClass("Action", Relationship::ManyToOneType());
$roleQuery =& $permissionQuery->queryRelationedClass("Role", Relationship::ManyToOneType());
$roleUserQuery =& $roleQuery->queryRelationedClass("RoleUser");
$userQuery =& $roleUserQuery->queryRelationedClass("User", Relationship::ManyToOneType());
// Criterias
$criteriaGroup = new CriteriaGroup();
$actionCriteria = new Criteria($actionQuery, "action", $action->getAction());
$userCriteria = new Criteria($userQuery, "ID", $user->getId());
$criteriaGroup->addCriterion($actionCriteria);
$criteriaGroup->addCriterion($userCriteria);
$classQuery->setCriterion($criteriaGroup);
// sorting
$order = new Order($classQuery, "title", "ASC");
$classQuery->addOrder($order);
// Execute the query
$recordset =& $classQuery->execute();
$array = $this->mapAll($recordset);
return $array;
}
开发者ID:BackupTheBerlios,项目名称:icf-svn,代码行数:32,代码来源:baseClassMapper.php
示例8: setContent
/**
* Inenhåller menun som passar till Art
* subkategprierna ordnas efter orderNo i matrushkan.
*/
public function setContent()
{
$q = new Query("matruschkaShowAtPlaces");
$q->showAt($this->title, $this->m->lang, "msapOrderNo", "ASC", 100);
$i = 1;
while ($row = mysql_fetch_object($q->getResult())) {
$this->content .= '<div class="leftMenu">';
$this->content .= '<span class="subSecTitle">' . $row->mButtonTitle . '</span>';
$qq = new Query("matruschka");
$qq->whereCustom("mButtonTitle, mRowid", "mParent = '" . $row->mRowid . "' AND mPublished='1' AND mLang='" . $this->m->lang . "' ", "mOrderNo", "ASC", 0);
if ($qq->getNumRows()) {
// om det finns nån som har denna som parent
$this->content .= '<div class="subSection">';
while ($row2 = mysql_fetch_object($qq->getResult())) {
/** Svart om aktiv **/
if ($this->getActive($this->m->ID, $row2->mRowid) == 1) {
$this->content .= '<span class="sideMenuActive"><a href="?ID=' . $row2->mRowid . '">' . $row2->mButtonTitle . '</a></span><br/>';
} else {
$this->content .= '<a href="?ID=' . $row2->mRowid . '">' . $row2->mButtonTitle . '</a><br/>';
}
}
$this->content .= '</div>';
}
$this->content .= '</div>';
if ($i != $q->getNumRows()) {
$this->content .= '<img src="' . Settings::$graphics . 'stripes.gif" />' . "\n";
}
$i++;
}
}
开发者ID:rocafuerte,项目名称:standard2,代码行数:34,代码来源:ItaMenu.class.php
示例9: add_error
function add_error($_id)
{
$c = new Query();
$c->where_eq('id', $_id);
$c->value('error_cnt', 'error_cnt+1', true);
$this->update($c);
}
开发者ID:byyeong,项目名称:dc2016,代码行数:7,代码来源:model.php
示例10: check
function check($_type)
{
$c = new Query();
$c->where_eq("name", $_type);
$res = $this->fetch_one("id", $c);
return $res;
}
开发者ID:byyeong,项目名称:dc2016,代码行数:7,代码来源:Event_type.php
示例11: __construct
public function __construct($settings)
{
$query = new Query($settings, array('xtimes' => 1, 'ytimes' => 1));
$query->acceptInteger('xtimes', '/^[1-9][0-9]*$/');
$query->acceptInteger('ytimes', '/^[1-9][0-9]*$/');
$this->settings = $query->results();
}
开发者ID:psychoticmeowArchives,项目名称:Imaje,代码行数:7,代码来源:tile.php
示例12: getData
/**
* get an array of data to use in the response
* @param Query $query the query to use to retrieve the data
* @param Paginator $paginator
* @param array $additionalData an associative array of data to merge with the data array
*/
protected function getData($query, $additionalData = array())
{
//use this hook to alter the parameters
$paginator = null;
if (Input::get('page') || $this->paginate) {
$beforePagination = Event::fire('before.pagination', array(&$query));
//check if $object is a model or a relation
$model = $query->getModel();
$model = method_exists($model, 'getRelated') ? $model->getRelated() : $model;
$perPage = Input::get('pp') ?: $model->getPerPage();
$paginator = $query->paginate($perPage);
//preserve the url query in the paginator
$paginator->appends(Input::except('page'));
}
$results = isset($paginator) ? $paginator->getCollection() : $query->get();
$data = array();
$data[$this->resultsKey] = $this->isAjaxRequest() ? $results->toArray() : $results;
$data['total'] = isset($paginator) ? $paginator->getTotal() : $data->{$this->resultsKey}->count();
if ($paginator) {
$data['paginator'] = $paginator;
}
if (is_array($additionalData)) {
$data = array_merge($data, $additionalData);
}
return $data;
}
开发者ID:whitegolem,项目名称:laracrud,代码行数:32,代码来源:CrudController.php
示例13: setContent
public function setContent()
{
$q = new Query("matruschkaShowAtPlaces");
$q->showAt("Menubar", $this->m->lang, "mOrderNo", "ASC", 10);
$a = array();
$i = 0;
while ($row = mysql_fetch_object($q->getResult())) {
// Get the id and image
$a[$i][0] = $row->mRowid;
$a[$i][1] = $row->mButtonTitle;
$a[$i][2] = $row->mButtonImage;
$i++;
}
for ($i = 0; $i < count($a); $i++) {
$im = split(',', $a[$i][2]);
$this->content .= '<span class="menuItem">' . "\n";
$this->content .= "<a href=\"?ID=" . $a[$i][0] . "\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('" . $im[1] . "','','" . Settings::$graphics . "menu/" . $this->m->lang . "/" . $im[1] . "',1)\">";
// Den man är inne på blir röd
$image = $this->getActive($this->m->ID, $a[$i][0]) ? $im[1] : $im[0];
$this->content .= '<img src="' . Settings::$graphics . 'menu/' . $this->m->lang . '/' . $image . '" alt="' . $im[1] . '" name="' . $im[1] . '" border="0" id="' . $im[1] . '" />';
$this->content .= '</a>';
if ($i < count($a) - 1) {
$this->content .= '<img src="' . Settings::$graphics . 'menu/' . $this->m->lang . '/stripe.gif" width="7" height="12" />';
}
$this->content .= "</span>\n";
}
}
开发者ID:rocafuerte,项目名称:standard2,代码行数:27,代码来源:SiteMenubar.class.php
示例14: edit
function edit($_id, $_state)
{
$c = new Query();
$c->value("visible", $_state);
$c->where_eq("id", $_id);
$this->update($c);
}
开发者ID:byyeong,项目名称:dc2016,代码行数:7,代码来源:Member_grade.php
示例15: startQuery
public function startQuery($sql, $parameters = null, $stack = array())
{
if (!$this->enabled) {
return null;
}
// try to detect the query type
switch (strtolower(substr(ltrim($sql), 0, 6))) {
case 'select':
$queryType = static::SELECT;
break;
case 'insert':
$queryType = static::INSERT;
break;
case 'update':
$queryType = static::UPDATE;
break;
case 'delete':
$queryType = static::DELETE;
break;
default:
$queryType = static::QUERY;
break;
}
$profile = new Query($sql, $queryType, $parameters, $stack);
$this->profiles[] = $profile;
$profile->start();
end($this->profiles);
return key($this->profiles);
}
开发者ID:Baft,项目名称:Zend-Form,代码行数:29,代码来源:Profiler.php
示例16: publications_userapi_getitemlinks
/**
* utility function to pass individual item links to a caller
*
* @param $args['itemids'] array of item ids to get
* @return array Array containing the itemlink(s) for the item(s).
*/
function publications_userapi_getitemlinks($args)
{
$itemlinks = array();
sys::import('xaraya.structures.query');
$xartable = xarDB::getTables();
$q = new Query('SELECT', $xartable['publications']);
$q->addfield('id');
$q->addfield('title');
$q->addfield('description');
$q->addfield('pubtype_id');
$q->in('state', array(3, 4));
if (!empty($args['itemids'])) {
$itemids = explode(',', $args['itemids']);
$q->in('id', $itemids);
}
$q->addorder('title');
$q->run();
$result = $q->output();
if (empty($result)) {
return $itemlinks;
}
foreach ($result as $item) {
if (empty($item['title'])) {
$item['title'] = xarML('Display Publication');
}
$itemlinks[$item['id']] = array('url' => xarModURL('publications', 'user', 'display', array('id' => $item['id'])), 'title' => $item['title'], 'label' => $item['description']);
}
return $itemlinks;
}
开发者ID:godboko,项目名称:modules,代码行数:35,代码来源:getitemlinks.php
示例17: parseInto
/**
* Parse a query string into a Query object.
*
* @param Query $query Query object to populate
* @param string $str Query string to parse
* @param bool|string $urlEncoding How the query string is encoded
*/
public function parseInto(Query $query, $str, $urlEncoding = true)
{
if ($str === '') {
return;
}
$result = [];
$this->duplicates = false;
$this->numericIndices = true;
$decoder = self::getDecoder($urlEncoding);
foreach (explode('&', $str) as $kvp) {
$parts = explode('=', $kvp, 2);
$key = $decoder($parts[0]);
$value = isset($parts[1]) ? $decoder($parts[1]) : null;
// Special handling needs to be taken for PHP nested array syntax
if (strpos($key, '[') !== false) {
$this->parsePhpValue($key, $value, $result);
continue;
}
if (!isset($result[$key])) {
$result[$key] = $value;
} else {
$this->duplicates = true;
if (!is_array($result[$key])) {
$result[$key] = [$result[$key]];
}
$result[$key][] = $value;
}
}
$query->replace($result);
if (!$this->numericIndices) {
$query->setAggregator(Query::phpAggregator(false));
} elseif ($this->duplicates) {
$query->setAggregator(Query::duplicateAggregator());
}
}
开发者ID:hellsigner,项目名称:guzzle5-legacy,代码行数:42,代码来源:QueryParser.php
示例18: listDemos
public function listDemos(Paging $paging){
while($row = mysql_fetch_assoc($paging->pagingResult)){
if($row['rowid']==$_GET['demo_id']) continue;
// Got to make a new query beacuse of error in mysql_fetch_assoc
$query = new Query($this->q->getTable());
$query->whereLeftJoinImageQuery("*","image_id",$row['image_id'],"rowid","ASC");
$image_id = $query->getResultRow("image_id");
$file_name=$query->getResultRow("file");
?>
<table border="0" cellpadding="0" cellspacing="0" class="demoTable">
<tr>
<?php
if(Helper::hasValue($image_id)){
?>
<td width="80" class="noPadding" rowspan="2"><img src="image_crop.php?source=<?php echo Settings::getUploadedImages().'/'.$file_name ?>&dest=&thumb_size=80" class="flowPic" /></td>
<?php
}
?>
<td width="270" class="tdPadding" colspan="2"><span class="boldGrey"><?php echo $row['name']; ?></span></td>
</tr>
<tr>
<td class="tdVertBottom"><span class="smallPink"><a href="?demo_id=<?php echo $row['rowid']; ?>">Läs mer</a></span></td>
<td align="right" class="tdVertBottom"><span class="smallGrey"><?php echo date("Y-m-d",strtotime($row['date'])); ?></span></td>
</tr>
</table>
<?
}
}
开发者ID:rocafuerte,项目名称:opus,代码行数:29,代码来源:ShowDemos.class.php
示例19: getTable
/**
* Метод получает все содержимое таблицы $this->tableName по запросу SELECT и записывает в свойство $this->tableFormDB
* вызывает метод draw() и возвращет готовую таблицу
* @return string
*/
public function getTable(){
$query = new Query();
$sql = "SELECT * FROM `{$this->tableName}`";
$this->tableFromDB = $query->runSql($sql);
return $this->draw();
}
开发者ID:ruslanBik4,项目名称:allservice_in_ua,代码行数:12,代码来源:tableDrawing.php
示例20: setItems
public function setItems()
{
// Items at level
$date = $this->matruschka ? $this->matruschka->pubDate : date("Y-m-d H:i:s");
// Order number
$orderQ = new Query("matruschka");
if ($parent) {
$orderQ->whereQuery("mOrderNo", "mParent", $parent, 'mOrderNo', 'DESC', 1);
$order = $orderQ->getResultRow('mOrderNo') + 1;
} else {
$order = 1;
}
$orderNo = $this->matruschka ? $this->matruschka->orderNo : $order;
$this->items[0][] = new ItemImage($this->matruschka->ID, $this->matruschka->images, "Bild. 200 x _ px", 1);
$this->items[0][] = new ItemTitle($this->matruschka->ID, $this->matruschka->title, "Titel", 0);
$this->items[0][] = new ItemButtonTitle($this->matruschka->ID, $this->matruschka->buttonTitle, "KnappTitel (Mest för navigering i adminsidan)", 0);
$this->items[0][] = new ItemButtonImage($this->matruschka->ID, $this->matruschka->buttonImage, "Knappbild t.ex (bild1.gif,bild2.gif)", 0);
$this->items[0][] = new ItemDescription($this->matruschka->ID, $this->matruschka->description, "Text", 0);
$this->items[0][] = new ItemPublished($this->matruschka->ID, $this->matruschka->published, "Publicerad", 0);
$this->items[0][] = new ItemOrderNo($this->matruschka->ID, $orderNo, "Ordningsnummer. Till menyraden.", 0);
$this->items[1][] = new ItemButtonTitle($this->matruschka->ID, $this->matruschka->buttonTitle, "Knapptitel", 0);
$this->items[1][] = new ItemPublished($this->matruschka->ID, $this->matruschka->published, "Publicerad", 0);
$this->items[1][] = new ItemOrderNo($this->matruschka->ID, $orderNo, "Ordningsnummer. Till vänstermenyn.", 0);
$this->items[2][] = new ItemImage($this->matruschka->ID, $this->matruschka->images, "Bild. 200 x _ px", 1);
$this->items[2][] = new ItemButtonTitle($this->matruschka->ID, $this->matruschka->buttonTitle, "Knapptitel", 0);
$this->items[2][] = new ItemTitle($this->matruschka->ID, $this->matruschka->title, "Titel", 0);
$this->items[2][] = new ItemDescription($this->matruschka->ID, $this->matruschka->description, "Text (All text här)", 0);
$this->items[2][] = new ItemPublished($this->matruschka->ID, $this->matruschka->published, "Publicerad", 0);
$this->items[2][] = new ItemOrderNo($this->matruschka->ID, $orderNo, "Ordningsnummer. Till vänstermenyn.", 0);
}
开发者ID:rocafuerte,项目名称:standard2,代码行数:30,代码来源:AdminTextShow.class.php
注:本文中的Query类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论