当前位置: 首页>>代码示例>>PHP>>正文


PHP Query::setQuery方法代码示例

本文整理汇总了PHP中Query::setQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::setQuery方法的具体用法?PHP Query::setQuery怎么用?PHP Query::setQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query::setQuery方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addReport

 private function addReport($options, $connection)
 {
     $report = new Report();
     $report->setDescription(self::generateDescription());
     $report->setTitle(implode(', ', array_keys($options['queries'])));
     $report->save();
     foreach ($options['queries'] as $key => $value) {
         $query = new Query();
         $query->setQuery($key);
         $query->save();
         $report_query = new ReportQuery();
         $report_query->setQuery($query);
         $report_query->setTitle($key);
         $report_query->setReport($report);
         $report_query->save();
         $date_start = strtotime($options['start_date']);
         $date_end = strtotime($options['end_date']);
         $start = $value['rand_start'];
         while ($date_start < $date_end) {
             if (rand(0, 100) > $value['rand']) {
                 $query_result = new QueryResultBulk();
                 $query_result->setQuery($query);
                 $start += rand($value['rand_min'], $value['rand_max']) * $value['rand_diff'];
                 $query_result->setResultSize($start);
                 $query_result->setCreatedAt($date_start);
                 $query_result->save();
             }
             $date_start = strtotime(date('Y-m-d', $date_start) . ' +1 days');
         }
         $sql = "DELETE FROM %s where date(%s) = '%s' and %s = %s";
         $sql = sprintf($sql, QueryResultPeer::TABLE_NAME, QueryResultPeer::RESULT_DATE, date('Y-m-d'), QueryResultPeer::QUERY_ID, $query->getId());
         $statement = $connection->prepareStatement($sql);
         $statement->executeQuery();
     }
     $tags = self::generateTags();
     foreach ($tags as $tag) {
         $tag->setReport($report);
         $tag->save();
     }
 }
开发者ID:hoydaa,项目名称:googlevolume.com,代码行数:40,代码来源:TestDataTask.class.php

示例2: Query

<?php

if (!empty($_GET['key'])) {
    require 'src/class/Query.php';
    $query = new Query();
    $res = $query->setQuery($_GET['key'])->getKeywords();
    if (@$_GET['json']) {
        echo $res;
    } else {
        if (sizeof(json_decode(json_decode($res)->data)) > 0) {
            if (!empty($_GET['id'])) {
                $query->_setId($_GET['id']);
                $result = $query->getDetailsData();
                if ($result['success'] === 0) {
                    echo $result['message'];
                    return false;
                }
                foreach ($result['data'] as $key => $value) {
                    echo $key . ': ' . $value . '<br/>';
                }
            } else {
                $res = json_decode(json_decode($res)->data, true);
                foreach ($res as $key => $value) {
                    echo '<a href="?key=' . $_GET['key'] . '&id=' . $value['id'] . '"> ' . $value['location'] . '</a><br/>';
                }
            }
        } else {
            echo 'No any result fouund';
        }
    }
} else {
开发者ID:samundrak,项目名称:php-mysql-ajax-jquery-live-search,代码行数:31,代码来源:query.php

示例3: die

<?php

ob_start();
/**
 * @author Evin Weissenberg 2013
 */
mysql_connect('localhost', 'econline_mv', 'KeHG9.C9,n0b') or die(mysql_error());
mysql_select_db('econline_mv') or die(mysql_error());
include 'lib/Query.php';
include 'lib/Satitize.php';
$s = new Sanitize();
$data = $s->cleanArray($_REQUEST);
$q = new Query();
$go = $q->setQuery("UPDATE mv_users SET user_type='" . $data['type'] . "' WHERE ID=" . $data['ID'])->run();
header('Location: /user/admin/');
开发者ID:evinw,项目名称:project_modelv,代码行数:15,代码来源:add_type.php

示例4: deleteUser

 /**
  * @param Query $q
  * @param $user_id
  */
 function deleteUser(Query $q, $user_id)
 {
     $q->setQuery('Delete user')->run();
 }
开发者ID:ew-evidence-backup,项目名称:php_boilerplate,代码行数:8,代码来源:Auth.php

示例5: testNamedBinds

 public function testNamedBinds()
 {
     $query = new Query($this->db);
     $query->setQuery('SELECT * FROM users WHERE id = :id OR name = :name', ['id' => 13, 'name' => 'Geoffrey']);
     $expected = "SELECT * FROM users WHERE id = 13 OR name = 'Geoffrey'";
     $this->assertEquals($expected, $query->getQuery());
 }
开发者ID:titounnes,项目名称:CodeIgniter4,代码行数:7,代码来源:BaseQueryTest.php

示例6: updateObjectFromForm

 protected function updateObjectFromForm()
 {
     if ($this->object->getId()) {
         foreach ($this->object->getReportQuerys() as $report_query) {
             $report_query->delete();
         }
         foreach ($this->object->getReportTags() as $tag) {
             $tag->delete();
         }
     }
     $this->object->setTitle($this->getValue('title'));
     $this->object->setDescription($this->getValue('description'));
     $this->object->setMailFrequency($this->getValue('frequency'));
     if ($this->getValue('private') == 'on') {
         $this->object->setPublicRecord(false);
     } else {
         $this->object->setPublicRecord(true);
     }
     $tag_names = explode(',', $this->getValue('tags'));
     foreach ($tag_names as $tag_name) {
         if (!($tag_name = strtolower(trim($tag_name)))) {
             continue;
         }
         $tag = new ReportTag();
         $tag->setName($tag_name);
         $this->object->addReportTag($tag);
     }
     $query_texts = explode("\n", str_replace("\r", "", $this->getValue('query_texts')));
     $query_titles = explode("\n", str_replace("\r", "", $this->getValue('query_titles')));
     for ($i = 0; $i < sizeof($query_texts); $i++) {
         $query_text = $query_texts[$i];
         $query_title = $query_titles[$i];
         if ($query_text) {
             $query = QueryPeer::retrieveByQUERY($query_text);
             if (!$query) {
                 $query = new Query();
                 $query->setQuery($query_text);
             }
             $report_query = new ReportQuery();
             $report_query->setQuery($query);
             $report_query->setTitle($query_title);
             $this->object->addReportQuery($report_query);
         }
     }
     if ($this->getValue('user_id')) {
         $this->object->setUserId($this->getValue('user_id'));
     }
 }
开发者ID:hoydaa,项目名称:googlevolume.com,代码行数:48,代码来源:NewReportForm.class.php


注:本文中的Query::setQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。