--- title: "Primary index" description: "Learn how to perform scans and manage primary index queries using the Aerospike PHP client." --- # Primary index > For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt) > > All documentation pages available in markdown. The following code example demonstrates a primary index query with the PHP client. ```php sendKey = true; // Ensure server returns the key upon write // Add sample user data to the server $userKeys = []; for ($i = 0; $i put($writePolicy, $key, $userBins); $userKeys[] = $key; // Store keys for later retrieval } // Define bins to retrieve during scan $scanBins = ["username", "email", "age"]; // Define scan policy $scanPolicy = new ScanPolicy(); $pf = PartitionFilter::all(); // Perform scan $recordSet = $client->scan($scanPolicy, $pf, $namespace, $set, $scanBins); // Iterate over scan results while ($record = $recordSet->next()) { // Access bin values of each record $username = $record->bins["username"]; $email = $record->bins["email"]; $age = $record->bins["age"]; // Display retrieved data echo "Username: $username, Email: $email, Age: $age\n"; } // Close record set after processing $recordSet->close(); ```