Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taq/torm
Just another simple PHP ORM. You can use it, but don't ask me why I made it. :-)
https://github.com/taq/torm
activerecord orm php
Last synced: 7 days ago
JSON representation
Just another simple PHP ORM. You can use it, but don't ask me why I made it. :-)
- Host: GitHub
- URL: https://github.com/taq/torm
- Owner: taq
- License: gpl-2.0
- Created: 2013-05-26T15:33:41.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-03-08T11:13:01.000Z (almost 3 years ago)
- Last Synced: 2024-12-13T11:47:31.023Z (13 days ago)
- Topics: activerecord, orm, php
- Language: PHP
- Size: 358 KB
- Stars: 95
- Watchers: 22
- Forks: 30
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TORM
| :warning: **WARNING** This software is [abandonware](https://en.wikipedia.org/wiki/Abandonware). As the creator and maintainer, I don't even use PHP _for years_, so, I can't support it anymore. It should work ok for PHP untill version 7, but seems that with 8.1 there are some alerts. Feel free to fork it and keep it going. |
| --- |Just another simple ORM for PHP. You can use it, but don't ask why I made it. Right? :-)
## Usage
Take a look on the [Github Wiki](https://github.com/taq/torm/wiki) for documentation, but let me show the basics here:
```php
true]);
User::validates("email", ["presence" => true]);
User::validates("email", ["uniqueness" => true]);
User::validates("id", ["numericality" => true]);// create some relations
User::hasMany("tickets");
User::hasOne("account");
Ticket::belongsTo("user");// this will create a new user
$user = new User();
$user->name = "John Doe";
$user->email = "[email protected]";
$user->level = 1;
$user->save();// this will find the user using its primary key
$user = User::find(1);// find some users
$users = User::where(["level" => 1]);// find some users, using more complex expressions
// the array first element is the query, the rest are values
$users = User::where(["level >= ?", 1]);// updating users
User::where(["level" => 1])->updateAttributes(["level" => 3]);// using fluent queries
$users = User::where(["level" => 1])->limit(5)->order("name desc");// listing the user tickets
foreach($user->tickets as $ticket) {
echo $ticket->description;
}// show user account info
echo $user->account->number;
?>
```## Testing
### SQLite
First, use `composer update` to make sure everything is ok with all the
packages. Then, go to the `test` directory and run `run`. It will requires the
[SQLite driver](http://php.net/manual/en/ref.pdo-sqlite.php) so make sure it is
available. If not, check the `php.ini` dir found with```bash
$ php -r 'phpinfo();' | grep 'php.ini'
Configuration File (php.ini) Path => /etc/php/7.1/cli
Loaded Configuration File => /etc/php/7.1/cli/php.ini
```and, if not found there or on the `conf.d` on the same location the `php.ini`
file is, it can be installed, on Ubuntu, using:```bash
$ sudo apt install php-sqlite3
```### Multibyte strings, locale and YAML
```
$ sudo apt install php-mbstring php-intl php-yaml
```