當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AQueryWriter::setSQLFilters方法代碼示例

本文整理匯總了PHP中RedBeanPHP\QueryWriter\AQueryWriter::setSQLFilters方法的典型用法代碼示例。如果您正苦於以下問題:PHP AQueryWriter::setSQLFilters方法的具體用法?PHP AQueryWriter::setSQLFilters怎麽用?PHP AQueryWriter::setSQLFilters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RedBeanPHP\QueryWriter\AQueryWriter的用法示例。


在下文中一共展示了AQueryWriter::setSQLFilters方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSQLFilters

 /**
  * Test whether we can use SQL filters and
  * whether they are being applied properly for
  * different types of SELECT queries in the QueryWriter.
  */
 public function testSQLFilters()
 {
     R::nuke();
     AQueryWriter::setSQLFilters(array(QueryWriter::C_SQLFILTER_READ => array('book' => array('title' => ' LOWER(book.title) ')), QueryWriter::C_SQLFILTER_WRITE => array('book' => array('title' => ' UPPER(?) '))));
     $book = R::dispense('book');
     $book->title = 'story';
     R::store($book);
     asrt(R::getCell('SELECT title FROM book WHERE id = ?', array($book->id)), 'STORY');
     $book = $book->fresh();
     asrt($book->title, 'story');
     $library = R::dispense('library');
     $library->sharedBookList[] = $book;
     R::store($library);
     $library = $library->fresh();
     $books = $library->sharedBookList;
     $book = reset($books);
     asrt($book->title, 'story');
     $otherBook = R::dispense('book');
     $otherBook->sharedBook[] = $book;
     R::store($otherBook);
     $otherBook = $otherBook->fresh();
     $books = $otherBook->sharedBookList;
     $book = reset($books);
     asrt($book->title, 'story');
     $links = $book->ownBookBookList;
     $link = reset($links);
     $link->shelf = 'x13';
     AQueryWriter::setSQLFilters(array(QueryWriter::C_SQLFILTER_READ => array('book' => array('title' => ' LOWER(book.title) '), 'book_book' => array('shelf' => ' LOWER(book_book.shelf) ')), QueryWriter::C_SQLFILTER_WRITE => array('book' => array('title' => ' UPPER(?) '), 'book_book' => array('shelf' => ' UPPER(?) '))));
     R::store($link);
     asrt(R::getCell('SELECT shelf FROM book_book WHERE id = ?', array($link->id)), 'X13');
     $otherBook = $otherBook->fresh();
     unset($book->sharedBookList[$otherBook->id]);
     R::store($book);
     AQueryWriter::setSQLFilters(array());
 }
開發者ID:gabordemooij,項目名稱:redbean,代碼行數:40,代碼來源:Update.php

示例2: bindFunc

 /**
  * Binds an SQL function to a column.
  * This method can be used to setup a decode/encode scheme or
  * perform UUID insertion. This method is especially useful for handling
  * MySQL spatial columns, because they need to be processed first using
  * the asText/GeomFromText functions.
  *
  * @param string $mode     mode to set function for, i.e. read or write
  * @param string $field    field (table.column) to bind SQL function to
  * @param string $function SQL function to bind to field
  *
  * @return void
  */
 public function bindFunc($mode, $field, $function)
 {
     list($type, $property) = explode('.', $field);
     $mode = $mode === 'write' ? QueryWriter::C_SQLFILTER_WRITE : QueryWriter::C_SQLFILTER_READ;
     if (!isset(self::$sqlFilters[$mode])) {
         self::$sqlFilters[$mode] = array();
     }
     if (!isset(self::$sqlFilters[$mode][$type])) {
         self::$sqlFilters[$mode][$type] = array();
     }
     if (is_null($function)) {
         unset(self::$sqlFilters[$mode][$type][$property]);
     } else {
         if ($mode === QueryWriter::C_SQLFILTER_WRITE) {
             self::$sqlFilters[$mode][$type][$property] = $function . '(?)';
         } else {
             self::$sqlFilters[$mode][$type][$property] = $function . "({$field})";
         }
     }
     AQueryWriter::setSQLFilters(self::$sqlFilters, !$this->isFrozen);
 }
開發者ID:nekrasovdmytro,項目名稱:redbean,代碼行數:34,代碼來源:OODB.php


注:本文中的RedBeanPHP\QueryWriter\AQueryWriter::setSQLFilters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。