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


PHP Facade::flat方法代碼示例

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


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

示例1: array_flatten

 function array_flatten($array)
 {
     return \RedBeanPHP\Facade::flat($array);
 }
開發者ID:WTer,項目名稱:NJB,代碼行數:4,代碼來源:rb.php

示例2: testINClause

 /**
  * Test forming IN-clause using genSlots and flat.
  *
  * @return void
  */
 public function testINClause()
 {
     list($flowers, $shop) = R::dispenseAll('flower*4,shop');
     $flowers[0]->color = 'red';
     $flowers[1]->color = 'yellow';
     $flowers[2]->color = 'blue';
     $flowers[3]->color = 'purple';
     $flowers[0]->price = 10;
     $flowers[1]->price = 15;
     $flowers[2]->price = 20;
     $flowers[3]->price = 25;
     $shop->xownFlowerList = $flowers;
     R::store($shop);
     $colors = array('red', 'yellow');
     $result = $this->getColors(R::find('flower', ' color IN (' . R::genSlots($colors) . ' ) AND price < ?', R::flat(array($colors, 100))));
     asrt($result, 'red,yellow');
     $colors = array('red', 'yellow');
     $result = $this->getColors(R::find('flower', ' color IN (' . R::genSlots($colors) . ' ) AND price < ?', R::flat(array($colors, 10))));
     asrt($result, '');
     $colors = array('red', 'yellow');
     $result = $this->getColors(R::find('flower', ' color IN (' . R::genSlots($colors) . ' ) AND price < ?', R::flat(array($colors, 15))));
     asrt($result, 'red');
     asrt(json_encode(R::flat(array('a', 'b', 'c'))), '["a","b","c"]');
     asrt(json_encode(R::flat(array('a', array('b'), 'c'))), '["a","b","c"]');
     asrt(json_encode(R::flat(array('a', array('b', array('c'))))), '["a","b","c"]');
     asrt(json_encode(R::flat(array(array('a', array('b', array(array('c'))))))), '["a","b","c"]');
     asrt(json_encode(R::flat(array('a', 'b', 'c', array()))), '["a","b","c"]');
     asrt(genslots(array(1, 2)), '?,?');
     asrt(json_encode(array_flatten(array(array('a', array('b', array(array('c'))))))), '["a","b","c"]');
     asrt(genslots(array(1, 2), 'IN (%s) AND'), 'IN (?,?) AND');
     asrt(genslots(array(), ' IN (%s) AND '), '');
     $colors = array('blue', 'purple', 'red');
     $flowers = R::find('flower', genslots($colors, ' color IN (%s) AND ') . ' price > ? ', array_flatten(array($colors, 11)));
     asrt($this->getColors($flowers), 'blue,purple');
     $flowers = R::find('flower', genslots(array(), ' color IN (%s) AND ') . ' price > ? ', array_flatten(array(array(), 11)));
     asrt($this->getColors($flowers), 'blue,purple,yellow');
     $flowers = R::find('flower', ' id > 0 AND ' . genslots($colors, ' color IN (%s) AND ') . ' price > ? ', array_flatten(array($colors, 11)));
     asrt($this->getColors($flowers), 'blue,purple');
     $flowers = R::find('flower', ' id > 0 AND ' . genslots(array(), ' color IN (%s) AND ') . ' price > ? ', array_flatten(array(array(), 11)));
     asrt($this->getColors($flowers), 'blue,purple,yellow');
 }
開發者ID:gabordemooij,項目名稱:redbean,代碼行數:46,代碼來源:Finding.php


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