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


PHP ORM::get_last_query方法代码示例

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


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

示例1: find

 public function find($tag, $key = "tags")
 {
     // search pages table with pages that has a certain tag
     $r = \ORM::for_table('cms_page')->distinct()->select('cms_page.*')->join('cms_page_meta', array('cms_page.id', '=', 'cms_page_meta.page_id'))->join('cms_page_meta_translation', array('cms_page_meta.id', '=', 'cms_page_meta_translation.meta_id'))->where_equal('cms_page_meta.key', $key)->where_raw("FIND_IN_SET({$tag}, cms_page_meta_translation.value)")->find_many();
     print_r($r);
     print_r(\ORM::get_last_query());
 }
开发者ID:netdust,项目名称:ntdst-cms,代码行数:7,代码来源:TagController.php

示例2: testPrefixOnAutoTableNameWithTableSpecified

 public function testPrefixOnAutoTableNameWithTableSpecified()
 {
     Model::$auto_prefix_models = 'MockPrefix_';
     Model::factory('TableSpecified')->find_many();
     $expected = 'SELECT * FROM `simple`';
     $this->assertEquals($expected, ORM::get_last_query());
 }
开发者ID:arunkapil,项目名称:Granada,代码行数:7,代码来源:ModelPrefixingTest.php

示例3: index

 public function index()
 {
     $_SESSION['tableData'] = array();
     // Checks whether or not user is logged in
     self::checkLogin();
     // enable query profiling
     Flight::get('db')->query('SET profiling = 1;');
     // get specified table data as array
     $records = ORM::for_table(Flight::get('lastSegment'))->find_array();
     //pretty_print($records);
     // find out time above query was ran for
     $exec_time_result = Flight::get('db')->query('SELECT query_id, SUM(duration) FROM information_schema.profiling GROUP BY query_id ORDER BY query_id DESC LIMIT 1;');
     $exec_time_row = $exec_time_result->fetchAll(PDO::FETCH_NUM);
     // table columns
     $stmt = Flight::get('db')->query("DESCRIBE " . Flight::get('lastSegment'));
     $columns = $stmt->fetchAll(PDO::FETCH_ASSOC);
     //pretty_print($columns);
     $fields = array();
     foreach ($columns as $values) {
         if (isset($values['Field'])) {
             $fields[] = $values['Field'];
         }
     }
     //pretty_print($fields);
     // store table fields/columns + data rows in session for exporting later
     $_SESSION['tableData'] = array_merge($fields, $records);
     $fieldTypes = array();
     /*
     foreach ($columns as $values) {
         if (isset($values['Field'])) {
             $fieldTypes['type'][] = $values['Type'];
             $fieldTypes['primary'][] = $values['Key'];
         }
     }
     //pretty_print($fieldTypes, false);
     */
     $records = Presenter::listTableData($records, $fieldTypes);
     Flight::render('table', array('title' => Flight::get('lastSegment'), 'icon' => self::$icon, 'table_data' => $records, 'fields' => getOptions($fields), 'query' => SqlFormatter::format(ORM::get_last_query(ORM::DEFAULT_CONNECTION)), 'timetaken' => $exec_time_row[0][1]));
 }
开发者ID:bubach,项目名称:VisualQuery,代码行数:39,代码来源:table.php

示例4: catch

<?php

try {
    // include the autoload file, which will include any other required files
    //
    require_once __DIR__ . '/../vendor/autoload.php';
    // handle any "bootstrapping" - application-wide configuration tasks
    //
    require_once __DIR__ . '/../bootstrap.php';
    // start the route processor
    //
    require_once __DIR__ . '/../routes.php';
} catch (Exception $e) {
    // oh no!
    echo "<h1>Unhandled Exception!</h1>";
    echo "\n<!--\n\n";
    print_r($e);
    echo "-->\n\n";
    // dump the exception
    Kint::dump($e);
    // if database logging is enabled...
    if (Config::get('database.logging')) {
        // try to get the last query (or a "none" message if there isn't one)
        $last = ORM::get_last_query() ?: '-- none --';
        // report the last query
        echo "<h2>Last Query</h2>";
        echo "<pre>{$last}</pre>";
    }
}
开发者ID:monstergfx,项目名称:pi-music,代码行数:29,代码来源:index.php

示例5: generate_location_query

    if ($location_before_ts) {
        $location_query->where_lt("timestamp", $location_before_ts);
    } else {
        $location_query->order_by_desc("timestamp");
    }
    return $location_query;
}
if (DO_LOCATIONS) {
    $openpath_query = generate_location_query($location_before_ts, $location_after_ts);
    $openpath_query->where("source", "openpaths");
    $openpath_rows = $openpath_query->find_array();
    $return['log'][] = ORM::get_last_query();
    $foursquare_query = generate_location_query($location_before_ts, $location_after_ts);
    $foursquare_query->where_not_equal("source", "openpaths");
    $foursquare_rows = $foursquare_query->find_array();
    $return['log'][] = ORM::get_last_query();
    // echo "<pre>";
    // var_dump($openpath_rows);
    // echo "\n\n";
    // var_dump(ORM::get_last_query());
    // die("HellO");
    $locations = array();
    $location_rows = array_merge($openpath_rows, $foursquare_rows);
    foreach ($openpath_rows as $row) {
        if (!$row['lat'] || !$row['long']) {
            continue;
        }
        if ($row['title']) {
            $title = $row['title'];
        } else {
            $title = $row['timestamp'];
开发者ID:aquarion,项目名称:Lifestream,代码行数:31,代码来源:fetchNext.php

示例6: testHasManyThroughRelationWithCustomIntermediateModelAndKeyNames

 public function testHasManyThroughRelationWithCustomIntermediateModelAndKeyNames()
 {
     $book2 = Model::factory('BookTwo')->find_one(1);
     $authors2 = $book2->authors()->find_many();
     $expected = "SELECT `author`.* FROM `author` JOIN `author_book` ON `author`.`id` = `author_book`.`custom_author_id` WHERE `author_book`.`custom_book_id` = '1'";
     $this->assertEquals($expected, ORM::get_last_query());
 }
开发者ID:arunkapil,项目名称:Granada,代码行数:7,代码来源:GranadaTest.php

示例7: array

ORM::for_table('widget')->find_one(5);
$expected = "SELECT * FROM `widget` WHERE `primary_key` = '5' LIMIT 1";
Tester::check_equal("Setting: id_column", $expected);
ORM::configure('id_column_overrides', array('widget' => 'widget_id', 'widget_handle' => 'widget_handle_id'));
ORM::for_table('widget')->find_one(5);
$expected = "SELECT * FROM `widget` WHERE `widget_id` = '5' LIMIT 1";
Tester::check_equal("Setting: id_column_overrides, first test", $expected);
ORM::for_table('widget_handle')->find_one(5);
$expected = "SELECT * FROM `widget_handle` WHERE `widget_handle_id` = '5' LIMIT 1";
Tester::check_equal("Setting: id_column_overrides, second test", $expected);
ORM::for_table('widget_nozzle')->find_one(5);
$expected = "SELECT * FROM `widget_nozzle` WHERE `primary_key` = '5' LIMIT 1";
Tester::check_equal("Setting: id_column_overrides, third test", $expected);
ORM::for_table('widget')->use_id_column('new_id')->find_one(5);
$expected = "SELECT * FROM `widget` WHERE `new_id` = '5' LIMIT 1";
Tester::check_equal("Instance ID column, first test", $expected);
ORM::for_table('widget_handle')->use_id_column('new_id')->find_one(5);
$expected = "SELECT * FROM `widget_handle` WHERE `new_id` = '5' LIMIT 1";
Tester::check_equal("Instance ID column, second test", $expected);
ORM::for_table('widget_nozzle')->use_id_column('new_id')->find_one(5);
$expected = "SELECT * FROM `widget_nozzle` WHERE `new_id` = '5' LIMIT 1";
Tester::check_equal("Instance ID column, third test", $expected);
// Test caching. This is a bit of a hack.
ORM::configure('caching', true);
ORM::for_table('widget')->where('name', 'Fred')->where('age', 17)->find_one();
ORM::for_table('widget')->where('name', 'Bob')->where('age', 42)->find_one();
$expected = ORM::get_last_query();
ORM::for_table('widget')->where('name', 'Fred')->where('age', 17)->find_one();
// this shouldn't run a query!
Tester::check_equal("Caching, same query not run twice", $expected);
Tester::report();
开发者ID:zilionis,项目名称:idiorm,代码行数:31,代码来源:test_queries.php

示例8: check_query

 /**
  * Check the provided string is equal to the last
  * query generated by the dummy database class.
  */
 public static function check_query($test_name, $query)
 {
     $last_query = ORM::get_last_query();
     if ($query === $last_query) {
         self::report_pass($test_name);
     } else {
         self::report_failure($test_name, $query, $last_query);
     }
 }
开发者ID:powerpak,项目名称:dakota,代码行数:13,代码来源:test_classes.php

示例9: get_last_query

 public function get_last_query()
 {
     return \ORM::get_last_query($this->connectionName);
 }
开发者ID:arseniew,项目名称:silex-idiorm-provider,代码行数:4,代码来源:IdiormService.php

示例10: last_query

 public function last_query()
 {
     return Query::get_last_query();
 }
开发者ID:phpwax,项目名称:db,代码行数:4,代码来源:SQLBackend.php

示例11: implode

    }
    echo implode(";", $items);
});
$app->post('/genv/payhulu', function ($request, $response) {
    $uid = $_SESSION['uid'];
    $amount = $this->request->getParam("amount");
    try {
        ORM::get_db()->setAttribute(PDO::ATTR_AUTOCOMMIT, 0);
        ORM::get_db()->beginTransaction();
        //减去余额
        $sql = vsprintf("UPDATE %s SET `balance` = balance-%d WHERE `uid` = %d and `balance`>=%d ", array(table("members_points"), $amount, $uid, $amount));
        ORM::raw_execute($sql);
        //增加积分;
        $sql = vsprintf("UPDATE %s SET `points` = points+%d WHERE `uid` = %d   ", array(table("members_points"), $amount, $uid));
        ORM::raw_execute($sql);
        echo ORM::get_last_query();
        //
        //        Order::deduct_stock($order['coohua_id'], $order['product_id'], $order['order_code']);
        //        ORM::raw_execute("UPDATE `order` SET `check` = 5 WHERE `order_code` = ? and `check`=4 ", array($order['order_code']));
        ORM::get_db()->commit();
        ORM::get_db()->setAttribute(PDO::ATTR_AUTOCOMMIT, 1);
    } catch (Exception $e) {
        //dump($e);
        ORM::get_db()->rollBack();
    }
});
function listDir($dir)
{
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
            while (($file = readdir($dh)) !== false) {
开发者ID:winiceo,项目名称:job,代码行数:31,代码来源:leven.php

示例12: testStaticBackwardsCompatibilityNotices

 public function testStaticBackwardsCompatibilityNotices()
 {
     // adding the return until the fix has been implemented.
     $this->setExpectedException('PHPUnit_Framework_Error_Notice');
     ORM::for_table('widget')->find_many();
     $expected = "SELECT * FROM `widget`";
     $this->assertEquals($expected, ORM::get_last_query());
 }
开发者ID:kevinsperrine,项目名称:idiorm,代码行数:8,代码来源:IdiormSQLiteTest.php

示例13: view

<?php 
view('header');
?>


<div class="starter-template">
	<h1>An error occured!</h1>

	<p class="lead"><?php 
o($error->getMessage());
?>
</p>
	<p class="lead"><?php 
o(\ORM::get_last_query());
?>
</p>
	<div class="left-aligned">
		<?php 
dbg($error);
?>
	</div>
</div>

<?php 
view('footer');
开发者ID:agroff,项目名称:FindPuppies,代码行数:25,代码来源:default.php

示例14: getLastQuery

 public function getLastQuery()
 {
     return \ORM::get_last_query();
 }
开发者ID:ingeting,项目名称:silex-service-providers,代码行数:4,代码来源:ParisProvider.php


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