1. Go to this page and download the library: Download kingsoft/persist-db library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kingsoft / persist-db example snippets
declare(strict_types=1);
use \Kingsoft\Persist\Db\Bootstrap;
$bootstrap = new Bootstrap( 'Realm\Namespace', ROOT );
$bootstrap->discover();
$bootstrap = new Bootstrap( 'Realm\Namespace' );
$bootstrap->discover();
// Database Configuration
$db = [
'hostname' => 'localhost',
'database' => 'db',
'username' => 'user',
'password' => 'pass'
];
// Output the configuration as an array (if needed for debugging)
define( 'SETTINGS', [
'db' => $db,
]);
unset($db);
public static function getPrimaryKey():string { return ''; }
public static function isPrimaryKeyAutoIncrement():bool { return false; }
public static function getPrimaryKey():string { return 'your_unique_field'; }
// This works - reading all records from a view
foreach( ViewName::findAll() as $record ) {
echo $record->field_name;
}
// This works - finding specific records
$record = ViewName::find(['field' => '=value']);
// This will NOT work - views don't support updates
// $record->freeze(); // Don't do this!
// This will NOT work - no primary key to identify records
// $record = new ViewName(123); // Don't do this!
declare(strict_types=1);
use \Kingsoft\Persist\Db\Bootstrap;
$bootstrap = new Bootstrap( 'Kingsoft\LinkQr', ROOT );
$bootstrap->document(
ROOT.'doc-header.html',
ROOT.'doc-footer.html'
);
url
https://example.com/discover.php
sh
composer dump-autoload
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.