{"id":221521,"date":"2014-04-30T19:13:03","date_gmt":"2014-04-30T15:13:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=221521"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=221521","title":{"rendered":"<span class=\"post_title\">\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 Php extension \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0434 Cassandra \u0431\u0435\u0437 Thrift<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0445\u0430\u0431\u0440\u0430\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e!<br \/>  \u0414\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0431\u0430\u0437\u043e\u0439 Cassandra \u0438\u0437 php \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432 \u0441\u0435\u0431\u0435 Thrift \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043a\u0430\u043a deprecated \u0435\u0449\u0451 \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 0.8. <br \/>  \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u0437\u0435 CQL (Cassandra Query Language), \u043d\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u043e\u0434 php \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0443\u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u0442. \u0412 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/datastax\">Datastax<\/a> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0434\u043b\u044f C++, Java, C# \u0438 Python. \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0441\u0430\u043c Php \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u0421\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0437\u0430\u043a\u0430\u0442\u0430\u0432 \u0440\u0443\u043a\u0430\u0432\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 C++ \u0441 Php. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0447\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u2014 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041a\u0430\u043a \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u043f\u043b\u044e\u0441\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0441 Php \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0430 <a href=\"http:\/\/devzone.zend.com\/1435\/wrapping-c-classes-in-a-php-extension\/\">\u0434\u0435\u0432\u0437\u043e\u043d\u0435 \u0437\u0435\u043d\u0434\u0430<\/a>. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u043c\u043d\u043e\u0433\u0438\u043c \u044d\u0442\u0430 \u0441\u0441\u044b\u043b\u043a\u0430 \u0443\u0436\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0430\u0441\u044c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u044c \u043a\u0430\u043a-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043f\u043e\u0434 Php. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043c\u0430\u043a\u0440\u043e\u0441 PHP_REQUIRE_CXX() \u0432 config.m4, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0443\u0447\u043d\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 stdc++, \u0435\u0441\u043b\u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432\u044b \u0435\u0451 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<p>  \u0421\u0431\u043e\u0440\u043a\u0430 C++ \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Datastax&#8217;\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430 \u0438 \u0432\u0441\u0435 \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044d\u0442\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/datastax\/cpp-driver.git <\/code><\/pre>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Boost, Openssl \u0438 Cmake \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0449\u0451 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440<\/p>\n<pre><code class=\"bash\">cd cpp-driver cmake . && make && make install <\/code><\/pre>\n<p>  <i>\u0425\u0438\u043d\u0442: make install \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0442.\u00a0\u043a. \u0432\u0441\u0435 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044d\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 libcql.so.0.7.0 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0438\u043c\u043b\u0438\u043d\u043a <br \/>  <\/i>  <\/p>\n<pre><code class=\"bash\">ln -s libcql.so.0.7.0 \/usr\/lib\/libcql.so.0 ln -s \/usr\/lib\/libcql.so.0 \/usr\/lib\/libcql.so <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 wrapper:<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/aparkhomenko\/php-cassandra.git cd php-cassandra phpize && .\/configure && make <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u043f\u0430\u043f\u043a\u0435 modules \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c extension \u0434\u043b\u044f Php cassandra.so<br \/>  \u041c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0443 \u043d\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e:<\/p>\n<pre><code class=\"bash\">php -d=&quot;extension=modules\/cassandra.so&quot; -m <\/code><\/pre>\n<p>  \u0412 \u0441\u043f\u0438\u0441\u043a\u0435 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0430\u0434\u043f\u0438\u0441\u044c cassandra. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u2014 \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e; \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u043f\u0440\u043e\u0448\u0443 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \ud83d\ude42<\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043a\u043b\u0430\u0441\u0441\u044b: CqlBuilder, CqlCluster, CqlError, CqlFutureResult, CqlQuery, CqlSession, CqlResult.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f:<\/p>\n<pre><code class=\"php\">\/\/ Suppose you have the Cassandra cluster at 127.0.0.1,  \/\/ listening at default port (9042). $builder  = new CqlBuilder(); $builder-&gt;addContactPoint(&quot;127.0.0.1&quot;);  \/\/ Now build a model of cluster and connect it to DB. $cluster  = $builder-&gt;build(); $session  = $cluster-&gt;connect();  \/\/ Write a query, switch keyspaces. $query    = new CqlQuery('SELECT * FROM system.schema_keyspaces');  \/\/ Send the query. $future   = $session-&gt;query($query);  \/\/ Wait for the query to execute; retrieve the result. $future-&gt;wait(); $result   = $future-&gt;getResult();  if (null === $future-&gt;getError()) {      echo &quot;rowCount: {$result-&gt;getRowCount()}\\n&quot;;      while ($result-&gt;next()) {         echo &quot;strategy_options: &quot; . $result-&gt;get(&quot;strategy_options&quot;) . &quot;\\n&quot;;     }  }  \/\/ Boilerplate: close the connection session and perform the cleanup. $session-&gt;close(); $cluster-&gt;shutdown(); <\/code><\/pre>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/221521\/\"> http:\/\/habrahabr.ru\/post\/221521\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0445\u0430\u0431\u0440\u0430\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e!<br \/>  \u0414\u0443\u043c\u0430\u044e \u043c\u043d\u043e\u0433\u0438\u0435 \u043a\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0431\u0430\u0437\u043e\u0439 Cassandra \u0438\u0437 php \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u0432\u0441\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432 \u0441\u0435\u0431\u0435 Thrift \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d \u043a\u0430\u043a deprecated \u0435\u0449\u0451 \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 0.8. <br \/>  \u0412\u043c\u0435\u0441\u0442\u043e \u043d\u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u0437\u0435 CQL (Cassandra Query Language), \u043d\u043e \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u043e\u0434 php \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 \u0443\u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u0442. \u0412 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/datastax\">Datastax<\/a> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0434\u043b\u044f C++, Java, C# \u0438 Python. \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0441\u0430\u043c Php \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u043d\u0430 \u0421\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0437\u0430\u043a\u0430\u0442\u0430\u0432 \u0440\u0443\u043a\u0430\u0432\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 C++ \u0441 Php. \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0447\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u2014 \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434 \u043a\u0430\u0442.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-221521","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/221521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=221521"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/221521\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=221521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=221521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=221521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}