PHPLinq 2차원 배열 employees 예제 2

1 사전 작업[ | ]

2 employees2.php 작성[ | ]

[root@zetawiki ~]# vi employees2.php
<?php
set_include_path(get_include_path().PATH_SEPARATOR.'/usr/share/php/vendor/phplinq/');
include 'PHPLinq/LinqToObjects.php';
function arrs2objs(&$a) { foreach($a as $k=>$v)$a[$k]=(object)$v; }

$employees = array(
	array('EmployeeID'=>'1', 'Name'=>'한놈', 'BirthDate'=>'2000-01-01'),
	array('EmployeeID'=>'2', 'Name'=>'두시기', 'BirthDate'=>'1990-01-01'),
	array('EmployeeID'=>'3', 'Name'=>'석삼', 'BirthDate'=>'1980-01-01'),
	array('EmployeeID'=>'4', 'Name'=>'너구리', 'BirthDate'=>'2000-01-01')
);
arrs2objs($employees);

$result = from('$employee')->in($employees)
	->where('$employee => $employee->BirthDate > "1985-01-01"')
	->orderByDescending('$employee => $employee->BirthDate')
	->thenBy('$employee => $employee->Name')
	->select('$employee');
print_r($result);

3 실행 결과[ | ]

[root@zetawiki ~]# php employees2.php
Array
(
    [0] => stdClass Object
        (
            [EmployeeID] => 4
            [Name] => 너구리
            [BirthDate] => 2000-01-01
        )

    [1] => stdClass Object
        (
            [EmployeeID] => 1
            [Name] => 한놈
            [BirthDate] => 2000-01-01
        )

    [2] => stdClass Object
        (
            [EmployeeID] => 2
            [Name] => 두시기
            [BirthDate] => 1990-01-01
        )

)

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}