1. Go to this page and download the library: Download coreorm/framework 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/ */
setDbConfig('default_database', [default db adaptor name]); // we need a default always
// or, alternatively, use
setDefaultDb([default db adaptor name]);
// next, set up the database adaptors in this way:
setDbConfig('database', array(
[adaptor name] => (array) [$options]
));
// use mysql as an example:
setDbConfig('database', array(
'main' => array(
'dbname' => 'my_db_name',
'user' => 'db_user_name',
'pass' => 'db_password',
'host' => '127.0.0.1',
'port' => 3306, // optional
'cache' => false, // default is false, true to enable cache in memory - NOTE: will increase memory usage
),
'db1' => array(
...
),
));
$dir = realpath(__DIR__ . '/Model/');
return array(
'database' => array(
'dbname' => 'model_test',
'user' => 'model',
'adaptor' => 'MySQL',
'pass' => 'test',
'host' => '127.0.0.1'
),
'path' => $dir,
'namespace' => 'Example\\Model',
'model' => array(
'user' => array(
'relations' => [
array(
'table' => 'login',
'join' => 'INNER',
'type' => 'S',
'on' => array(
// support multiple on conditions
// must be from left => right
'id' => 'user_id'
),
'condition' => ''
),
array(
'table' => 'attachment',
'join' => 'LEFT',
'type' => 'M',
'on' => array(
'id' => 'user_id'
),
'condition' => ''
)
],
),
'login' => array(
),
'attachment' => array(
'class' => 'File' // let's use a different name for the class...
),
)
);