{"id":25527186,"url":"https://github.com/bitendian/tbp","last_synced_at":"2025-04-11T06:11:50.708Z","repository":{"id":62494564,"uuid":"90986134","full_name":"Bitendian/tbp","owner":"Bitendian","description":"Light framed PHP library","archived":false,"fork":false,"pushed_at":"2022-10-14T11:18:34.000Z","size":1090,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T06:11:24.678Z","etag":null,"topics":["component-architecture","composer-package","light-framework","php-framework"],"latest_commit_sha":null,"homepage":"http://www.bitendian.com/en/portfolio/tbp-5/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bitendian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-11T14:05:00.000Z","updated_at":"2021-12-03T17:26:23.000Z","dependencies_parsed_at":"2022-11-02T11:31:39.070Z","dependency_job_id":null,"html_url":"https://github.com/Bitendian/tbp","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitendian%2Ftbp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitendian%2Ftbp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitendian%2Ftbp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bitendian%2Ftbp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bitendian","download_url":"https://codeload.github.com/Bitendian/tbp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248351395,"owners_count":21089270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component-architecture","composer-package","light-framework","php-framework"],"created_at":"2025-02-19T22:17:28.656Z","updated_at":"2025-04-11T06:11:50.666Z","avatar_url":"https://github.com/Bitendian.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TBP\n\n*TBP* is a light framework designed to develop small and medium\nwebsites. Focused in component oriented\n\n## Database interfaces\n\n### SQLite\nConnector to SQLite3. Works with prepared statements (mandatory). Support for transactions.\n\n#### Installation\nPHP extension ```ext-sqlite3``` required. Check ```phpinfo()```. By default, ```tbp-web-server``` Docker image supports SQLite.\n\nAdd to your ```composer.json```, at ```require``` section:\n```\n\"ext-sqlite3\": \"*\"\n```\n\n\n#### Configuration\nCreate a config file, like ```config/my-sqlite.config```\n```\n# TBP/SQLite config file.\n# ALL PARAMETERS ARE OPTIONAL!\n\n# Database file name (if not defined, will use 'default.db')\nfilename=resources/test.db\n\n# Access type\n# readOnly=yes\n\n# Encryption key (if not defined, no encryption used)\n# encryptionKey=\n```\n#### Implementation\n\nCreate a *Domain* extending ```AbstractSqliteDomain``` and pass your config file. Add one method for each needed query.\n```php\nclass MyDomain extends AbstractSqliteDomain\n{\n    public function __construct()\n    {\n        $configReader = new Config(__CONFIG_PATH__);            // \u003c-- get a config reader, passing your config folder\n        $config = $configReader-\u003egetConfig('my-sqlite');        // \u003c-- read your configuration, passing your config base name\n        $config-\u003efilename =                                     // \u003c-- convert your relative path into absolute path\n            __BASE_PATH__ .\n            DIRECTORY_SEPARATOR .\n            $config-\u003efilename;\n        parent::__construct($config);\n        $this-\u003eopen();                                          // \u003c-- open a db connection and let's rock!\n    }\n\n    public function addRegister($a, $b)\n    {\n        $sql = \"INSERT INTO `MyTableWithAutoInc` (`a`, `b`) VALUES (?, ?)\";\n        $params = array($a, $b);\n        return self::insertWithAutoincrement($this-\u003econnection-\u003ecommand($sql, $params));\n    }\n\n    public function addAnotherRegister($a, $b)\n    {\n        $sql = \"INSERT INTO `MyOtherTable` (`a`, `b`) VALUES (?, ?)\";\n        $params = array($a, $b);\n        return $this-\u003econnection-\u003ecommand($sql, $params);\n    }\n\n    public function getRegisters($b)\n    {\n        $sql = \"SELECT * FROM `MyTableWithAutoInc` WHERE `b` \u003c= ?\";\n        $params = array($b);\n        return self::getAll($this-\u003econnection-\u003eselect($sql, $params));\n    }\n\n    public function getRegisterById($id)\n    {\n        $sql = \"SELECT * FROM `MyTableWithAutoInc` WHERE `MyId` = ?\";\n        $params = array($id);\n        return self::getSingle($this-\u003econnection-\u003eselect($sql, $params));\n    }\n}\n```\n#### Usage\nsample straight-forward code:\n```php\n$domain = new MyDomain();\n$results = $domain-\u003egetRegisters(9391); // get an array\n```\nsample code with transactions:\n```php\n$domain = new MyDomain();\ntry {\n    $domain-\u003ebegin();\n    \n    $lastId = $domain-\u003eaddRegister(1, 2);\n    echo \"first query: last inserted id: $lastId\\n\";\n    \n    $lastId = $domain-\u003eaddRegister(3, 4);\n    echo \"second query: last inserted id: $lastId\\n\";\n    \n    $domain-\u003ecommit();\n} catch (Exception $e) {\n    $domain-\u003erollback();\n    echo \"ERROR: \" . $e-\u003egetMessage() . \"\\n\";\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitendian%2Ftbp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitendian%2Ftbp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitendian%2Ftbp/lists"}