当前位置: 首页>>代码示例>>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;未经允许,请勿转载。