首頁 > php教程 > php手册 > codeplex:PHP LINQ classes,PHP也可以使用Linq语法操作对象

codeplex:PHP LINQ classes,PHP也可以使用Linq语法操作对象

WBOY
發布: 2016-06-06 19:59:57
原創
1070 人瀏覽過

Examples can be found in the test package in the latest release. A basic example Let's say we have an array of strings and want to select only the strings whose length is 5. The PHPLinq way of achieving this would be the following: // Crea

Examples can be found in the test package in the latest release.

A basic example

Let's say we have an array of strings and want to select only the strings whose length is
// Create data source
$names = array("John", "Peter", "Joe", "Patrick", "Donald", "Eric"); 

$result = from('$name')->in($names)
            ->where('$name => strlen($name) select('$name'); 
登入後複製

Feels familiar to SQL? Yes indeed! No more writing a loop over this array, checking the string's length, and adding it to a temporary variable. 
You may have noticed something strange... What's that $name => strlen($name)

http://www.weiqinxue.cn/blogs/index.php/User/articleview/ArticleID/U2A15

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板