Accessing OrientDB from PHP

Looking for assistance with creating a PHP adapter for the binary API of OrientDB, specifically regarding socket communications.

Struggling to establish a connection between PHP and OrientDB, seeking help from someone familiar with raw socket communication in PHP.

If you have experience working with sockets, please check out this link for details on the issue I am facing.

Once we overcome the initial hurdle of sending a packet (refer to simplified examples at the bottom of the link), I can proceed with developing the adapter.

This project will be open source once completed.

Any assistance in getting started would be greatly appreciated. Thank you!


11/20/2010

Attempting to use PEAR's Net_Socket, but encountering challenges similar to those faced when using fsockopen() and regular PHP stream functions.

The server does not respond, causing the script to hang indefinitely until surpassing the general PHP time limit, despite setting a timeout.

Provided below is the code snippet being used:

<?php

header('Content-type: text/plain');

error_reporting(E_ALL | E_NOTICE | E_WARNING);

$txid = 123;
$db = 'demo';
$username = 'writer';
$password = 'writer';

// Packet creation
$packet = "\x05". # 1 byte
  pack('i',$txid). # 4 bytes
  pack('i',strlen($db)).$db. # string
  pack('i',strlen($username)).$username. # string
  pack('i',strlen($password)).$password; # string

hex_dump($packet);

$addr = '127.0.0.1';
$port = 2424;
$timeout = 5;
$errstr = '';
$errno = 0;

// Opening socket connection
$socket = fsockopen($addr, $port, $errno, $errstr, $timeout);

stream_set_blocking($socket, 1);
socket_set_timeout($socket, $timeout);

var_dump($socket);

fwrite($socket, $packet);

$response = '';

// Reading response from socket
while (!feof($socket))
  $response .= fread($socket, 1024);

hex_dump($response);

fclose($socket);

Additionally, here is the hex_dump() function utilized to analyze submitted packets:

<?php

function hex_dump($data, $newline="\n")
{
  // Function logic
}

As per Luca Garulli's assessment, the packet structure appears correct. Hence, the issue seems to stem from another source...

Could this problem be related to Windows compatibility? The setup involves PHP 5.3 running on Windows, under Apache...

Answer №1

I can't quite recall the specific issue, but I was able to resolve it in the end.

If anyone is searching for a functional example (whether related to OrientDB or another application), you're welcome to explore the code available in the public repository provided below:

https://github.com/mindplay-dk/OrientDB-PHP

Answer №2

Maybe the problem is related to a firewall restriction. Try adding a firewall exception or disabling the firewall temporarily.

Double check if the port number is correct. Have you tried connecting via telnet to that specific port?

> telnet 127.0.0.1 2424

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Prevent the submit button from being clicked again after processing PHP code and submitting the form (Using AJAX for

I've set up a voting form with submit buttons on a webpage. The form and PHP code work fine, and each time someone clicks the vote button for a specific option, it gets counted by 1. However, the issue is that users can spam the buttons since there i ...

nginx and php-fpm set up with a custom location rule that redirects to a

I have set up redirection from http to https and from non-www to www. However, I need to exclude two specific paths from being redirected to https. Despite numerous attempts at configuration, I keep encountering either a 404 error or being redirected to th ...

Unraveling the Quandary of Encoding

I've encountered an error message that states: It seems that I'm passing 3 parameters to the json_encode() function, while it expects only 2.</p> Interestingly, when I call the json_encode function, I am providing valid values for all thr ...

Exploring Joins in Laravel 4 Query Builder

In my database, I have tables named "airport" and "route". The "id" of "airport" is a foreign key in "route" (i.e. Origin, Destination). Airport +-------+-------------+-----------------------+ | id | airportcode | Location | +-------+--- ...

Displaying a Google chart with no data using JSON

Recently, I've been tackling the challenge of setting up Google Charts to display data from a local database. After some persistence, I believe I have successfully formatted the JSON output. { "cols": [ { "id": "", ...

Guide to adding table classes to AJAX response tables

I am facing an issue with displaying data in a table based on the AJAX request made. The problem arises because the data displayed does not follow the pagination classes applied to the table. My table has pagination functionality where 10 records are shown ...

Automatically reload main page in Javascript upon closing child window (popup)

I am working with 3 php files: view.php, edit.php, and edit2.php. In view.php, I display the content of my database tables. edit.php is used to edit a specific row using textboxes, while edit2.php is responsible for updating changes in the database. Once ...

Encountered a PHP Fatal error stating that the class 'Memcache' was not found in the object-cache.php file of WordPress, despite having successfully installed the memcache extension

I attempted to activate object cache for my Wordpress site using Memcache. I added the object-cache.php file to the /wp-content/ directory, obtained from the Memcached Object Cache plugin. However, I encountered a PHP Fatal error: Class 'Memcache&apo ...

Exporting MySQL data to MS Excel is functioning smoothly on the local environment, however, it is encountering difficulties when

<title>Orders Export</title> <body> <?php header('Content-Type: application/xls'); header('Content-Disposition: attachment; filename=download.xls'); $con = mysqli_connect('localhost','suresafe ...

Converting the content of a div into an image using PHP

Does anyone know a method in PHP to convert the HTML div content into a JPG or PNG image? <div class="canvas-object" style="background-color: rgb(247, 213, 183);"> <img id="img1" class="img" src="logo.png" style="width:110px; heigh ...

Tips for inserting additional spaces or lines into an XMLWriter PHP fileHere are some suggestions on

Currently, I am utilizing XMLWriter within php to construct a document. However, I am looking to enhance its formatting by inserting additional lines and spaces between elements and components. How can this be achieved? Please refer to the example below: ...

Import CSV data into MySQL database using PHP

Here is some PHP code: $handle = fopen($_FILES['filename']['tmp_name'], "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $import="INSERT into info(tazkira,gender,province,category,clin,training) values('$data[0 ...

Unable to present the information due to a codeigniter error in retrieving the data

Encountering an issue where the data cannot be displayed and it's showing an error message of undefined variable: avg. Below is the script being used: The controller function: public function rate_config() { $rt = $_POST['hasil_rating&a ...

Having trouble with adding a product to your cart after using the add_filter() function in woocommerce_add_to_cart_validation

In my current scenario, a non-logged-in user is restricted to adding only one product to their cart. I have implemented a filter on woocommerce_add_to_cart_validation that seems to be working correctly with $woocommerce->cart->cart_contents_count&g ...

Is it possible for a MySQL loop to only delete the first entry?

My MySQL looping is not working properly when I click the second button to get their id and continue with the rest of the process. Why is this happening? $(document).ready(function() { $("#deleteSchedule").click(function (e) { e.preventDefault(); ...

I can't figure out why this form isn't triggering the JS function. I'm attempting to create an autocomplete form field that connects to a MySQL database using a PHP script and AJAX

I am encountering an issue while trying to implement the .autocomplete() function from jQuery UI with a list of usernames fetched from a MySQL database using a PHP script. Strangely, it is not functioning as expected and no errors are being displayed in th ...

What is the method for determining the end date by using the start date and a pre-determined period that is stored in the

I need to determine the end date in SQL for inserting into a table with the following structure: Subscription_id(auto_increment)|service_id(int)|user_id|start_date|end_date The period is fixed and retrieved from another service table. Although I have a c ...

Utilize TinyMCE in your WordPress plugin

How can I integrate TinyMCE into my WordPress plugin? I have a textarea in the backend script that I would like to convert into a TinyMCE WYSIWYG editable field. Is there a method to achieve this? The following code snippet is not yielding the desired re ...

Sorting of unique elements in an array using PHP

I have been exploring the functionality of the array_unique function and according to the manual, it should also sort the values. However, when I test it with my sample code, I am not seeing the values being sorted. Here is the code snippet: $input = arra ...

What is the most efficient way to calculate the current percentage of time that has elapsed today

Is there a way to calculate the current time elapsed percentage of today's time using either JavaScript or PHP? Any tips on how to achieve this? ...