Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9277357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:05:18+00:00 2026-06-18T17:05:18+00:00

Can I specify what fields I want to receive from query when using HandlerSockets

  • 0

Can I specify what fields I want to receive from query when using HandlerSockets ?

Here is my sample table

CREATE TABLE pushed_media
(
    user_id BINARY(12) NOT NULL,
    story_id BINARY(12) NOT NULL,
    sent_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
    PRIMARY KEY ( user_id, story_id )
);

Php code that queries it is below

$hs = new HandlerSocket($host, $port);
if (!($hs->openIndex(1, $dbname, $table, HandlerSocket::PRIMARY, 'user_id,story_id,sent_date')))
{
    echo $hs->getError(), PHP_EOL;
    die();
}

$user_id = pack('H*', substr(md5('ruslan'), 0, 24));
$story_id = pack('H*', substr(md5('story1'), 0, 24));

$retval = $hs->executeSingle(1, '=', array($user_id, $story_id), 1, 0);

All I need is sent_date because I already know two other values. Is it possible to not to transfer them over the network again?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T17:05:19+00:00Added an answer on June 18, 2026 at 5:05 pm

    You can specify the fields that you want to receive from the query by simply specifying them in the field parameter of the openIndex method.
    As you can read here, this code:

    <?php
    $hs->openIndex(1, 'db', 'table', 'PRIMARY', 'k,v');
    $ret = $hs->executeSingle(1, '>=', array('K1'));
    var_dump($ret);
    ?>
    

    Is equivalent to the following SQL statement:

    SELECT k,v FROM table WHERE k >= 'K1' LIMIT 1
    

    Back to your example, if you want to read only the sent_date field value:

    $hs = new HandlerSocket($host, $port);
    if (!$hs->openIndex(1, $dbname, $table, myHandlerSocket::PRIMARY, 'sent_date')) {
        die($hs->getError());
    }
    
    $user_id  = pack('H*', substr(md5('ruslan'), 0, 24));
    $story_id = pack('H*', substr(md5('story1'), 0, 24));
    
    $retval = $hs->executeSingle(1, '=', array($user_id, $story_id), 1, 0);
    die("<pre>".print_r($retval,true)."</pre>");
    

    The resulting output should be something like this:

    Array
    (
        [0] => 0
        [1] => 1
        [2] => 2013-02-01 22:18:39
    )
    

    The HandlerSocket protocol documentation states:

    Once an ‘open_index’ request is issued, the HandlerSocket plugin opens
    the specified index and keep it open until the client connection is
    closed. Each open index is identified by <indexid>. If <indexid> is
    already open, the old open index is closed. You can open the same
    combination of <dbname> <tablename> <indexname> multple times,
    possibly with different <columns>.
    For efficiency, keep <indexid>
    small as far as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We can specify a derived from constraint on generic type parameters like this: class
When using Ninjects ConstructorArgument you can specify the exact value to inject to specific
When running a java program using the java command you can specify the verbose
I want to know I can dynamically modify an existing Crystal Report (using C#
Im my Java application, users can specify how to name their files from a
Let's pretend I want to set all the fields I specify to be =
I have a table with fields ID(primary key),Name and Address. how can i update
I want to load a plain file into Greenplum database using external tables. Can
I have a table with almost 40 fields in it. I want to update
In the Views module, if you set 'row style'=fields, you can specify which fields

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.