Comments (2)
Hi @peachp thank you for reaching out and for the the feedback! :)
You can use getContent() in order to retrieve a single record using the Record ID.
You just have to specify the 'recId' after the table name (tableName/recId).
This will return a single record, you won't need to loop through the records to retrieve the content.
Here's an example:
$request = $airtable->getContent( 'Tracks/recsJX1bry74HaGBh' );
$response = $request->getResponse();
echo $response->id;
I just did a simple benchmark test for each way. Using a table with less than 500 records, the results were very similar between the two. With a larger set of records, it was much faster to use the Record ID to retrieve your single record.
I hope this helps!
from airtable-php.
Hi. Thanks for the tip! Yes, it does help even if it won't be much faster, it is still cleaner compared to doing something like:
$params = array(
"filterByFormula" => "AND( RECORD_ID() = '$rec_id' )",
"maxRecords" => 1,
"pageSize" => 1
);
Thanks again and keep up the good work!
Btw, one of the projects I use your code in is a bespoke theme for the Grav CMS, which will allow to use Airtable as backend / DB for the website. Static pages like Homepage or Contact will be still created in Grav, but repeating, semi-dynamic content such as let's say Portfolio will be managed in Airtable, because it is more comfortable, and in our case we also use the same data for backend order processing. Of course it cannot replace a proper MySQL or similar, but for websites which don't have a lot of visitors and the content doesn't change that often, it's a good GUI / DB combination.
from airtable-php.
Related Issues (20)
- Keep manual reorder on fields links HOT 2
- Ability to enable typecast HOT 1
- Check if Airtable is down HOT 1
- Is there a way to add new column to table if not available? HOT 1
- Help - Multiple column search HOT 1
- PHP 8.1 compatibility (ReturnTypeWillChange) HOT 3
- Hey, there is a critical error. HOT 1
- Date field error! HOT 1
- how to append new record id to an existing field using your library HOT 1
- Get a NULL when trying to show some data HOT 10
- Please merge typecast PR HOT 2
- Add some degree of error handling HOT 1
- What does this error mean?
- Early heads up: switching away from user API keys HOT 4
- Accelerated need to limit large url requests to “list records”, with alternative POST version
- Not all records returned HOT 7
- Comment on Token HOT 2
- How to get specific fields only using formula?
- getting data from a table with "/" character in name
- new API authentication methods HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airtable-php.