最近在看.net的新功能linq,第一感觉,功能非常实用.
数组,字符串都可以用我们熟悉的 sql 方式来查询,太方便啦!
就想看看PHP在这方面有没有这样的类库.
不查不知道,一查吓一跳,还真的有类似的类库,命名为PHPLinq.
PHPLinq的首页:
http://www.codeplex.com/PHPLinq
Examples can be found in the test package in the latest release.
Let''s say we have an array of strings and want to select only the strings whose length is
DM建站系统汽车保养维修HTML5网站模板,DM企业建站系统。是由php+mysql开发的一套专门用于中小企业网站建设的开源cms。DM系统的理念就是组装,把模板和区块组装起来,产生不同的网站效果。可以用来快速建设一个响应式的企业网站( PC,手机,微信都可以访问)。后台操作简单,维护方便。DM企业建站系统安装步骤:第一步,先用phpmyadmin导入sql文件。 第二步:把文件放到你的本地服务器
1
立即学习“PHP免费学习笔记(深入)”;
// Create data source<br />$names = array("John", "Peter", "Joe", "Patrick", "Donald", "Eric"); <br /> <br />$result = from(''$name'')->in($names)<br /> ->where(''$name => strlen($name) < 5'')<br /> ->select(''$name''); <br />
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)
There are lots of other examples available in the PHPLinq download, but here''s an advanced one... Let''s say we have an array of Employee objects. This array should be sorted by Employee name, then Employee age. We want only Employees whose name has a length of 4 characters. Next thing: we do not want an Employee instance in our result. Instead, the returning array should contain objects containing an e-mail address and a domain name.
First of all, let''s define our data source:
class Employee {<br> public $Name;<br> public $Email;<br> public $Age;<br><br> public function __construct($name, $email, $age) {<br> $this->Name = $name;<br> $this->Email = $email;<br> $this->Age = $age;<br>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号