Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/z-song/simpleorm

simple data Orm based on PDO
https://github.com/z-song/simpleorm

Last synced: 30 days ago
JSON representation

simple data Orm based on PDO

Awesome Lists containing this project

README

        

SimpleOrm
=========

simple data Orm based on PDO

# Installing/Configuring
```
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
```
Then add
```
extension="SimpleOrm.so"
```
to your php.ini

#Usage

###SimpleOrm::getInstance(PDO $pdo)
```php
query('select * from actor');
```

###SimpleOrm::exec(string $query)
```php
exec('insert into actor (id, name, age)');
```

###SimpleOrm::select(string $table)
```php
select('actor');
```

###SimpleOrm::find(mixed)
```php
select('actor')->find();

//find record where id==2
$obj->select('actor')->find(2);

//find record where id in [1,2,4,5,6]
$obj->select('actor')->find([1,2,4,5,6]);
```

###SimpleOrm::field(string $columns)
```php
select('actor')->field('actor_id,first_name,last_name');
```

###SimpleOrm::where(string $where)
```php
select('actor')->field('actor_id,first_name,last_name')->where("where last_name='GABLE'");
```

###SimpleOrm::order(string $order)
```php
select('actor')->where("where last_name='GABLE'")->order('order by first_name desc');
```

###SimpleOrm::limit(int $limit[, $offset])
```php
select('actor')->where("where last_name='GABLE'")->limit(10);
//or
$obj->select('actor')->where("where last_name='GABLE'")->limit(10, 10);
```

###SimpleOrm::top(int $top)
```php
select('actor')->top(10);
```

###SimpleOrm::end(int $end)
```php
select('actor')->end(10);
```

###SimpleOrm::insert(string $table, array $data)
```php
insert('actor', array(...));
//or
$obj->table='actor';
$obj->insert(array(...));
```