Comments (2)
Sorry for the delay, I have been quite busy lately.
First of all, it is necessary to understand that database rows on Notion are essentially pages where the parent is the database.
Add a row to a database
<?php
require "vendor/autoload.php";
$token = "your_secret_here";
$notion = \Notion\Notion::create($token);
$databaseId = "your_database_id_here";
$parent = \Notion\Pages\PageParent::database($databaseId);
$title = \Notion\Pages\Properties\Title::create("Superbad");
$release = \Notion\Pages\Properties\Date::create(new DateTimeImmutable("2007-10-19"));
$category = \Notion\Pages\Properties\Select::fromName("Comedy")
->withColor(\Notion\Pages\Properties\Option::COLOR_BROWN);
$page = \Notion\Pages\Page::create($parent)
->withAddedProperty("Title", $title)
->withAddedProperty("Release date", $release)
->withAddedProperty("Category", $category);
$notion->pages()->create($page);
Change the value of a property
<?php
require "vendor/autoload.php";
$token = "your_secret_here";
$notion = \Notion\Notion::create($token);
$pageId = "your_page_id_here";
$page = $notion->pages()->find($pageId);
$updatedRelease = \Notion\Pages\Properties\Date::create(new DateTimeImmutable("2008-11-04"));
$updatedPage = $page->withAddedProperty("Release date", $updatedRelease);
$notion->pages()->update($updatedPage);
Since there are no examples of adding rows to a database and updating properties, I will leave this issue open.
Thanks for your feedback!
from notion-sdk-php.
Documentation is available on v0.6.2
- https://mario.engineering/notion-sdk-php/how-to/add-row-to-database.html
- https://mario.engineering/notion-sdk-php/how-to/update-a-page.html#update-properties
from notion-sdk-php.
Related Issues (20)
- [FEATURE] Use new `Empty` object instead of `stdClass` HOT 2
- [FEATURE] Correct PHP version requirement
- [BUG] Search all pages with Query::all() is not working correctly HOT 1
- [FEATURE] Support for block type in Notion\Databases\DatabaseParentType HOT 2
- [BUG] Typo in docs
- [BUG] Add & update File Property in pages HOT 3
- [FEATURE] Support for php7.4 HOT 1
- [BUG] Issue to submit an Image Block HOT 2
- Href links in Rich Text not working HOT 1
- [BUG] Update page error HOT 4
- Capacity to update a page with the new unique_id property HOT 5
- [FEATURE] Delete page properties HOT 3
- [BUG] Rollup properties are not working HOT 2
- [BUG] Unable to access ["date"] string HOT 1
- [FEATURE] Disable Time Display on Date Format HOT 2
- [BUG] ApiException fromResponse not handled properly causes TypeError
- How to read content in a tabpage HOT 2
- [BUG] - Add formula in $notUpdatableProps HOT 1
- Archived users causing UserType fatal error HOT 2
- [BUG] Undefined array key in User::fromArray on Page query
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 notion-sdk-php.