Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
f15abe7b
Commit
f15abe7b
authored
Oct 26, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes in examples and enabled header info for update queries by default
parent
72173059
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
12 deletions
+56
-12
examples/1.2-basic-select.php
examples/1.2-basic-select.php
+1
-1
examples/2.1.1-query-params.php
examples/2.1.1-query-params.php
+1
-2
examples/2.1.7-query-reuse.php
examples/2.1.7-query-reuse.php
+5
-3
examples/4.1-api-usage.php
examples/4.1-api-usage.php
+1
-2
examples/4.3-extending-usage.php
examples/4.3-extending-usage.php
+3
-3
examples/6.1.3-curl-adapter.php
examples/6.1.3-curl-adapter.php
+2
-0
examples/6.1.4-http-adapter.php
examples/6.1.4-http-adapter.php
+41
-0
examples/index.html
examples/index.html
+1
-0
library/Solarium/QueryType/Update/Query/Query.php
library/Solarium/QueryType/Update/Query/Query.php
+1
-1
No files found.
examples/1.2-basic-select.php
View file @
f15abe7b
...
...
@@ -7,7 +7,7 @@ htmlHeader();
$client
=
new
Solarium\Client
(
$config
);
// get a select query instance
$query
=
$client
->
createQuery
(
$client
::
QUERY_SELECT
,
array
(
'responsewriter'
=>
'phps'
)
);
$query
=
$client
->
createQuery
(
$client
::
QUERY_SELECT
);
// this executes the query and returns the result
$resultset
=
$client
->
execute
(
$query
);
...
...
examples/2.1.1-query-params.php
View file @
f15abe7b
<?php
require
(
__DIR__
.
'/init.php'
);
use
Solarium\QueryType\Select\Query\Query
as
Select
;
htmlHeader
();
...
...
@@ -21,7 +20,7 @@ $query->setStart(2)->setRows(20);
$query
->
setFields
(
array
(
'id'
,
'name'
,
'price'
));
// sort the results by price ascending
$query
->
addSort
(
'price'
,
Select
::
SORT_ASC
);
$query
->
addSort
(
'price'
,
$query
::
SORT_ASC
);
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
...
...
examples/2.1.7-query-reuse.php
View file @
f15abe7b
...
...
@@ -13,8 +13,10 @@ $client = new Client($config);
// first create a base query as a query class
class
PriceQuery
extends
Select
{
protected
function
_
init
()
protected
function
init
()
{
parent
::
init
();
// set a query (all prices starting from 12)
$this
->
setQuery
(
'price:[12 TO *]'
);
...
...
@@ -40,10 +42,10 @@ if(isset($_GET['start']) && is_numeric($_GET['start'])){
// in this example this class isn't actually used, but you can simple replace
// the var $query with an instance of this class...
class
LowerPriceQuery
extends
PriceQuery
{
protected
function
_
init
()
protected
function
init
()
{
// this call makes sure we get all the settings of the parent class
parent
::
_
init
();
parent
::
init
();
$this
->
setQuery
(
'price:[5 TO *]'
);
}
...
...
examples/4.1-api-usage.php
View file @
f15abe7b
<?php
require
(
__DIR__
.
'/init.php'
);
use
Solarium\QueryType\Select\Query\Query
as
Select
;
htmlHeader
();
...
...
@@ -15,7 +14,7 @@ $query = $client->createSelect();
$query
->
setQuery
(
'*:*'
);
$query
->
setStart
(
2
)
->
setRows
(
20
);
$query
->
setFields
(
array
(
'id'
,
'name'
,
'price'
));
$query
->
addSort
(
'price'
,
Select
::
SORT_ASC
);
$query
->
addSort
(
'price'
,
$query
::
SORT_ASC
);
// create a filterquery using the API
$fq
=
$query
->
createFilterQuery
(
'maxprice'
)
->
setQuery
(
'price:[1 TO 300]'
);
...
...
examples/4.3-extending-usage.php
View file @
f15abe7b
...
...
@@ -27,13 +27,13 @@ class ProductQuery extends Select{
}
// This query inherits all of the query params of its parent (using parent::
_
init) and adds some more
// This query inherits all of the query params of its parent (using parent::init) and adds some more
// Ofcourse it could also alter or remove settings
class
ProductPriceLimitedQuery
extends
ProductQuery
{
protected
function
_
init
()
protected
function
init
()
{
parent
::
_
init
();
parent
::
init
();
// create a filterquery
$this
->
createFilterQuery
(
'maxprice'
)
->
setQuery
(
'price:[1 TO 300]'
);
...
...
examples/6.1.3-curl-adapter.php
View file @
f15abe7b
...
...
@@ -10,6 +10,8 @@ htmlHeader();
$client
=
new
Solarium\Client
(
$config
);
// set the adapter to curl
// note that this is only shown for documentation purposes, normally you don't need
// to do this as curl is the default adapter
$client
->
setAdapter
(
'Solarium\Core\Client\Adapter\Curl'
);
// get a select query instance
...
...
examples/6.1.4-http-adapter.php
0 → 100644
View file @
f15abe7b
<?php
require_once
'Zend/Loader/Autoloader.php'
;
$loader
=
Zend_Loader_Autoloader
::
getInstance
();
require
(
__DIR__
.
'/init.php'
);
htmlHeader
();
// create a client instance
$client
=
new
Solarium\Client
(
$config
);
// set the adapter to curl
$client
->
setAdapter
(
'Solarium\Core\Client\Adapter\Http'
);
// get a select query instance
$query
=
$client
->
createSelect
();
// this executes the query and returns the result
$resultset
=
$client
->
select
(
$query
);
// display the total number of documents found by solr
echo
'NumFound: '
.
$resultset
->
getNumFound
();
// show documents using the resultset iterator
foreach
(
$resultset
as
$document
)
{
echo
'<hr/><table>'
;
// the documents are also iterable, to get all fields
foreach
(
$document
AS
$field
=>
$value
)
{
// this converts multivalue fields to a comma-separated string
if
(
is_array
(
$value
))
$value
=
implode
(
', '
,
$value
);
echo
'<tr><th>'
.
$field
.
'</th><td>'
.
$value
.
'</td></tr>'
;
}
echo
'</table>'
;
}
htmlFooter
();
\ No newline at end of file
examples/index.html
View file @
f15abe7b
...
...
@@ -113,6 +113,7 @@
<li><a
href=
"6.1.1-zend-http-adapter.php"
>
6.1.1 Zend_Http adapter
</a></li>
<li><a
href=
"6.1.2-pecl-http-adapter.php"
>
6.1.2 Pecl_Http adapter
</a></li>
<li><a
href=
"6.1.3-curl-adapter.php"
>
6.1.3 Curl adapter
</a></li>
<li><a
href=
"6.1.4-http-adapter.php"
>
6.1.4 Http adapter (PHP stream)
</a></li>
</ul>
<li><a
href=
"6.2-escaping.php"
>
6.2 Escaping
</a></li>
<li><a
href=
"6.3-placeholder-syntax.php"
>
6.3 Placeholder syntax
</a></li>
...
...
library/Solarium/QueryType/Update/Query/Query.php
View file @
f15abe7b
...
...
@@ -107,7 +107,7 @@ class Query extends BaseQuery
'handler'
=>
'update'
,
'resultclass'
=>
'Solarium\QueryType\Update\Result'
,
'documentclass'
=>
'Solarium\QueryType\Update\Query\Document'
,
'omitheader'
=>
tru
e
,
'omitheader'
=>
fals
e
,
);
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment