|
@@ -8,22 +8,22 @@
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- Table Storage is offered by Windows Azure as a REST API which is wrapped by the
|
|
|
|
|
- <classname>Zend_Service_WindowsAzure_Storage_Table</classname> class in order to provide a
|
|
|
|
|
- native PHP interface to the storage account.
|
|
|
|
|
|
|
+ Table Storage is offered by Windows Azure as a REST <acronym>API</acronym> which is wrapped
|
|
|
|
|
+ by the <classname>Zend_Service_WindowsAzure_Storage_Table</classname> class in order to
|
|
|
|
|
+ provide a native <acronym>PHP</acronym> interface to the storage account.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
This topic lists some examples of using the
|
|
This topic lists some examples of using the
|
|
|
- <classname>Zend_Service_WindowsAzure_Storage_Table</classname> class. Other features are
|
|
|
|
|
- available in the download package, as well as a detailed API documentation of those
|
|
|
|
|
- features.
|
|
|
|
|
|
|
+ <classname>Zend_Service_WindowsAzure_Storage_Table</classname> class. Other features are
|
|
|
|
|
+ available in the download package, as well as a detailed <acronym>API</acronym>
|
|
|
|
|
+ documentation of those features.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- Note that development table storage (in the Windows Azure SDK) does not support all features
|
|
|
|
|
- provided by the API. Therefore, the examples listed on this page are to be used on Windows
|
|
|
|
|
- Azure production table storage.
|
|
|
|
|
|
|
+ Note that development table storage (in the Windows Azure <acronym>SDK</acronym>) does not
|
|
|
|
|
+ support all features provided by the <acronym>API</acronym>. Therefore, the examples listed
|
|
|
|
|
+ on this page are to be used on Windows Azure production table storage.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<sect2 id="zend.service.windowsazure.storage.table.api">
|
|
<sect2 id="zend.service.windowsazure.storage.table.api">
|
|
@@ -83,17 +83,17 @@ foreach ($result as $table) {
|
|
|
<title>Operations on entities</title>
|
|
<title>Operations on entities</title>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- Tables store data as collections of entities. Entities are similar to rows. An entity
|
|
|
|
|
|
|
+ Tables store data as collections of entities. Entities are similar to rows. An entity
|
|
|
has a primary key and a set of properties. A property is a named, typed-value pair,
|
|
has a primary key and a set of properties. A property is a named, typed-value pair,
|
|
|
similar to a column.
|
|
similar to a column.
|
|
|
</para>
|
|
</para>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<para>
|
|
<para>
|
|
|
The Table service does not enforce any schema for tables, so two entities in the same
|
|
The Table service does not enforce any schema for tables, so two entities in the same
|
|
|
table may have different sets of properties. Developers may choose to enforce a schema
|
|
table may have different sets of properties. Developers may choose to enforce a schema
|
|
|
on the client side. A table may contain any number of entities.
|
|
on the client side. A table may contain any number of entities.
|
|
|
</para>
|
|
</para>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<para>
|
|
<para>
|
|
|
<classname>Zend_Service_WindowsAzure_Storage_Table</classname> provides 2 ways of
|
|
<classname>Zend_Service_WindowsAzure_Storage_Table</classname> provides 2 ways of
|
|
|
working with entities:
|
|
working with entities:
|
|
@@ -127,12 +127,12 @@ class SampleEntity extends Zend_Service_WindowsAzure_Storage_TableEntity
|
|
|
* @azure Name
|
|
* @azure Name
|
|
|
*/
|
|
*/
|
|
|
public $Name;
|
|
public $Name;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @azure Age Edm.Int64
|
|
* @azure Age Edm.Int64
|
|
|
*/
|
|
*/
|
|
|
public $Age;
|
|
public $Age;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @azure Visible Edm.Boolean
|
|
* @azure Visible Edm.Boolean
|
|
|
*/
|
|
*/
|
|
@@ -154,7 +154,7 @@ class SampleEntity extends Zend_Service_WindowsAzure_Storage_TableEntity
|
|
|
To enforce a schema on the client side using the
|
|
To enforce a schema on the client side using the
|
|
|
<classname>Zend_Service_WindowsAzure_Storage_Table</classname> class, you can create
|
|
<classname>Zend_Service_WindowsAzure_Storage_Table</classname> class, you can create
|
|
|
a class which inherits
|
|
a class which inherits
|
|
|
- <classname>Zend_Service_WindowsAzure_Storage_TableEntity</classname>. This class
|
|
|
|
|
|
|
+ <classname>Zend_Service_WindowsAzure_Storage_TableEntity</classname>. This class
|
|
|
provides some basic functionality for the
|
|
provides some basic functionality for the
|
|
|
<classname>Zend_Service_WindowsAzure_Storage_Table</classname> class to work with a
|
|
<classname>Zend_Service_WindowsAzure_Storage_Table</classname> class to work with a
|
|
|
client-side schema.
|
|
client-side schema.
|
|
@@ -210,12 +210,12 @@ class SampleEntity extends Zend_Service_WindowsAzure_Storage_TableEntity
|
|
|
* @azure Name
|
|
* @azure Name
|
|
|
*/
|
|
*/
|
|
|
public $Name;
|
|
public $Name;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @azure Age Edm.Int64
|
|
* @azure Age Edm.Int64
|
|
|
*/
|
|
*/
|
|
|
public $Age;
|
|
public $Age;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @azure Visible Edm.Boolean
|
|
* @azure Visible Edm.Boolean
|
|
|
*/
|
|
*/
|
|
@@ -249,7 +249,8 @@ public $<property name in PHP>;
|
|
|
storage:
|
|
storage:
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
- <example id="zend.service.windowsazure.storage.table.entities.enforced.schema-property-sample">
|
|
|
|
|
|
|
+ <example
|
|
|
|
|
+ id="zend.service.windowsazure.storage.table.entities.enforced.schema-property-sample">
|
|
|
<title>Sample enforced property</title>
|
|
<title>Sample enforced property</title>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
@@ -332,9 +333,10 @@ public $Age;
|
|
|
To use the <classname>Zend_Service_WindowsAzure_Storage_Table</classname> class
|
|
To use the <classname>Zend_Service_WindowsAzure_Storage_Table</classname> class
|
|
|
without defining a schema, you can make use of the
|
|
without defining a schema, you can make use of the
|
|
|
<classname>Zend_Service_WindowsAzure_Storage_DynamicTableEntity</classname> class.
|
|
<classname>Zend_Service_WindowsAzure_Storage_DynamicTableEntity</classname> class.
|
|
|
- This class inherits <classname>Zend_Service_WindowsAzure_Storage_TableEntity</classname>
|
|
|
|
|
- like an enforced schema class does, but contains additional logic to make it dynamic
|
|
|
|
|
- and not bound to a schema.
|
|
|
|
|
|
|
+ This class inherits
|
|
|
|
|
+ <classname>Zend_Service_WindowsAzure_Storage_TableEntity</classname> like an
|
|
|
|
|
+ enforced schema class does, but contains additional logic to make it dynamic and not
|
|
|
|
|
+ bound to a schema.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
@@ -378,7 +380,10 @@ public $Age;
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<example id="zend.service.windowsazure.storage.table.entities.dynamic.schema">
|
|
<example id="zend.service.windowsazure.storage.table.entities.dynamic.schema">
|
|
|
- <title>Dynamicaly adding properties to Zend_Service_WindowsAzure_Storage_DynamicTableEntity</title>
|
|
|
|
|
|
|
+ <title>
|
|
|
|
|
+ Dynamicaly adding properties to
|
|
|
|
|
+ Zend_Service_WindowsAzure_Storage_DynamicTableEntity
|
|
|
|
|
+ </title>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
|
$target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity(
|
|
$target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity(
|
|
@@ -393,8 +398,11 @@ $target->Age = 25; // Will add property "Age" of type "Edm.Int32"
|
|
|
Optionally, a property type can be enforced:
|
|
Optionally, a property type can be enforced:
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
- <example id="zend.service.windowsazure.storage.table.entities.dynamic.schema-forcedproperties">
|
|
|
|
|
- <title>Forcing property types on Zend_Service_WindowsAzure_Storage_DynamicTableEntity</title>
|
|
|
|
|
|
|
+ <example
|
|
|
|
|
+ id="zend.service.windowsazure.storage.table.entities.dynamic.schema-forcedproperties">
|
|
|
|
|
+ <title>
|
|
|
|
|
+ Forcing property types on Zend_Service_WindowsAzure_Storage_DynamicTableEntity
|
|
|
|
|
+ </title>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
|
$target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity(
|
|
$target = new Zend_Service_WindowsAzure_Storage_DynamicTableEntity(
|
|
@@ -404,7 +412,7 @@ $target->Name = 'Name'; // Will add property "Name" of type "Edm.String"
|
|
|
$target->Age = 25; // Will add property "Age" of type "Edm.Int32"
|
|
$target->Age = 25; // Will add property "Age" of type "Edm.Int32"
|
|
|
|
|
|
|
|
// Change type of property "Age" to "Edm.Int32":
|
|
// Change type of property "Age" to "Edm.Int32":
|
|
|
-$target->setAzurePropertyType('Age', 'Edm.Int64');
|
|
|
|
|
|
|
+$target->setAzurePropertyType('Age', 'Edm.Int64');
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
</example>
|
|
</example>
|
|
|
|
|
|
|
@@ -424,7 +432,7 @@ $target->setAzurePropertyType('Age', 'Edm.Int64');
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
Using the following code, an entity can be inserted into a table named
|
|
Using the following code, an entity can be inserted into a table named
|
|
|
- "testtable". Note that the table has already been created before.
|
|
|
|
|
|
|
+ "testtable". Note that the table has already been created before.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<example id="zend.service.windowsazure.storage.table.api.entities.insert.example">
|
|
<example id="zend.service.windowsazure.storage.table.api.entities.insert.example">
|
|
@@ -453,10 +461,11 @@ echo 'Etag: ' . $result->getEtag() . "\n";
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
Using the following code, an entity can be retrieved by partition key and row
|
|
Using the following code, an entity can be retrieved by partition key and row
|
|
|
- key. Note that the table and entity have already been created before.
|
|
|
|
|
|
|
+ key. Note that the table and entity have already been created before.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
- <example id="zend.service.windowsazure.storage.table.entities.api.retrieve-by-id.example">
|
|
|
|
|
|
|
+ <example
|
|
|
|
|
+ id="zend.service.windowsazure.storage.table.entities.api.retrieve-by-id.example">
|
|
|
<title>Retrieving an entity by partition key and row key</title>
|
|
<title>Retrieving an entity by partition key and row key</title>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
@@ -501,7 +510,8 @@ $result = $storageClient->updateEntity('testtable', $entity);
|
|
|
newer data.
|
|
newer data.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
- <example id="zend.service.windowsazure.storage.table.entities.api.updating.example-etag">
|
|
|
|
|
|
|
+ <example
|
|
|
|
|
+ id="zend.service.windowsazure.storage.table.entities.api.updating.example-etag">
|
|
|
<title>Updating an entity (with Etag check)</title>
|
|
<title>Updating an entity (with Etag check)</title>
|
|
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
<programlisting language="php"><![CDATA[
|
|
@@ -515,7 +525,7 @@ $entity = $storageClient->retrieveEntityById(
|
|
|
$entity->Name = 'New name';
|
|
$entity->Name = 'New name';
|
|
|
|
|
|
|
|
// last parameter instructs the Etag check:
|
|
// last parameter instructs the Etag check:
|
|
|
-$result = $storageClient->updateEntity('testtable', $entity, true);
|
|
|
|
|
|
|
+$result = $storageClient->updateEntity('testtable', $entity, true);
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
</example>
|
|
</example>
|
|
|
</sect4>
|
|
</sect4>
|
|
@@ -524,7 +534,7 @@ $result = $storageClient->updateEntity('testtable', $entity, true);
|
|
|
<title>Deleting an entity</title>
|
|
<title>Deleting an entity</title>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- Using the following code, an entity can be deleted. Note that the table and
|
|
|
|
|
|
|
+ Using the following code, an entity can be deleted. Note that the table and
|
|
|
entity have already been created before.
|
|
entity have already been created before.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
@@ -569,7 +579,7 @@ $result = $storageClient->deleteEntity('testtable', $entity);
|
|
|
</itemizedlist>
|
|
</itemizedlist>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- Using the following code, a table can be queried using a filter condition. Note
|
|
|
|
|
|
|
+ Using the following code, a table can be queried using a filter condition. Note
|
|
|
that the table and entities have already been created before.
|
|
that the table and entities have already been created before.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
@@ -593,7 +603,7 @@ foreach ($entities as $entity) {
|
|
|
</example>
|
|
</example>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- Using the following code, a table can be queried using a fluent interface. Note
|
|
|
|
|
|
|
+ Using the following code, a table can be queried using a fluent interface. Note
|
|
|
that the table and entities have already been created before.
|
|
that the table and entities have already been created before.
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
@@ -646,35 +656,37 @@ $storageClient = new Zend_Service_WindowsAzure_Storage_Table(
|
|
|
|
|
|
|
|
// Start batch
|
|
// Start batch
|
|
|
$batch = $storageClient->startBatch();
|
|
$batch = $storageClient->startBatch();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Insert entities in batch
|
|
// Insert entities in batch
|
|
|
$entities = generateEntities();
|
|
$entities = generateEntities();
|
|
|
foreach ($entities as $entity) {
|
|
foreach ($entities as $entity) {
|
|
|
$storageClient->insertEntity($tableName, $entity);
|
|
$storageClient->insertEntity($tableName, $entity);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Commit
|
|
// Commit
|
|
|
$batch->commit();
|
|
$batch->commit();
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
</example>
|
|
</example>
|
|
|
</sect3>
|
|
</sect3>
|
|
|
</sect2>
|
|
</sect2>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<sect2 id="zend.service.windowsazure.storage.table.sessionhandler">
|
|
<sect2 id="zend.service.windowsazure.storage.table.sessionhandler">
|
|
|
<title>Table storage session handler</title>
|
|
<title>Table storage session handler</title>
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
- When running a PHP application on the Windows Azure platform in a load-balanced mode
|
|
|
|
|
- (running 2 Web Role instances or more), it is important that PHP session data can be
|
|
|
|
|
- shared between multiple Web Role instances. The Windows Azure SDK for PHP provides the
|
|
|
|
|
|
|
+ When running a <acronym>PHP</acronym> application on the Windows Azure platform in a
|
|
|
|
|
+ load-balanced mode (running 2 Web Role instances or more), it is important that
|
|
|
|
|
+ <acronym>PHP</acronym> session data can be shared between multiple Web Role instances.
|
|
|
|
|
+ The Windows Azure <acronym>SDK</acronym> for <acronym>PHP</acronym> provides the
|
|
|
<classname>Zend_Service_WindowsAzure_SessionHandler</classname> class, which uses
|
|
<classname>Zend_Service_WindowsAzure_SessionHandler</classname> class, which uses
|
|
|
- Windows Azure Table Storage as a session handler for PHP applications.
|
|
|
|
|
|
|
+ Windows Azure Table Storage as a session handler for <acronym>PHP</acronym>
|
|
|
|
|
+ applications.
|
|
|
</para>
|
|
</para>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<para>
|
|
<para>
|
|
|
To use the <classname>Zend_Service_WindowsAzure_SessionHandler</classname> session
|
|
To use the <classname>Zend_Service_WindowsAzure_SessionHandler</classname> session
|
|
|
- handler, it should be registered as the default session handler for your PHP
|
|
|
|
|
- application:
|
|
|
|
|
|
|
+ handler, it should be registered as the default session handler for your
|
|
|
|
|
+ <acronym>PHP</acronym> application:
|
|
|
</para>
|
|
</para>
|
|
|
|
|
|
|
|
<example id="zend.service.windowsazure.storage.table.api.sessionhandler-register">
|
|
<example id="zend.service.windowsazure.storage.table.api.sessionhandler-register">
|
|
@@ -691,19 +703,20 @@ $sessionHandler = new Zend_Service_WindowsAzure_SessionHandler(
|
|
|
$sessionHandler->register();
|
|
$sessionHandler->register();
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
</example>
|
|
</example>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<para>
|
|
<para>
|
|
|
The above classname registers the
|
|
The above classname registers the
|
|
|
<classname>Zend_Service_WindowsAzure_SessionHandler</classname> session handler and will
|
|
<classname>Zend_Service_WindowsAzure_SessionHandler</classname> session handler and will
|
|
|
store sessions in a table called "sessionstable".
|
|
store sessions in a table called "sessionstable".
|
|
|
</para>
|
|
</para>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<para>
|
|
<para>
|
|
|
After registration of the
|
|
After registration of the
|
|
|
<classname>Zend_Service_WindowsAzure_SessionHandler</classname> session handler,
|
|
<classname>Zend_Service_WindowsAzure_SessionHandler</classname> session handler,
|
|
|
- sessions can be started and used in the same way as a normal PHP session:
|
|
|
|
|
|
|
+ sessions can be started and used in the same way as a normal <acronym>PHP</acronym>
|
|
|
|
|
+ session:
|
|
|
</para>
|
|
</para>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<example id="zend.service.windowsazure.storage.table.api.sessionhandler-usage">
|
|
<example id="zend.service.windowsazure.storage.table.api.sessionhandler-usage">
|
|
|
<title>Using table storage session handler</title>
|
|
<title>Using table storage session handler</title>
|
|
|
|
|
|
|
@@ -726,11 +739,11 @@ if (!isset($_SESSION['firstVisit'])) {
|
|
|
// ...
|
|
// ...
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
</example>
|
|
</example>
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
<warning>
|
|
<warning>
|
|
|
<para>
|
|
<para>
|
|
|
The <classname>Zend_Service_WindowsAzure_SessionHandler</classname> session handler
|
|
The <classname>Zend_Service_WindowsAzure_SessionHandler</classname> session handler
|
|
|
- should be registered before a call to <functionname>session_start()</functionname>
|
|
|
|
|
|
|
+ should be registered before a call to <methodname>session_start()</methodname>
|
|
|
is made!
|
|
is made!
|
|
|
</para>
|
|
</para>
|
|
|
</warning>
|
|
</warning>
|