Skip to content

Commit 06e5ab7

Browse files
committed
README.md updated.
1 parent 499121b commit 06e5ab7

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ Manage your database with or without abstraction. This library is built on the P
44

55
[![Latest Stable Version](http://poser.pugx.org/initphp/database/v)](https://packagist.org/packages/initphp/database) [![Total Downloads](http://poser.pugx.org/initphp/database/downloads)](https://packagist.org/packages/initphp/database) [![Latest Unstable Version](http://poser.pugx.org/initphp/database/v/unstable)](https://packagist.org/packages/initphp/database) [![License](http://poser.pugx.org/initphp/database/license)](https://packagist.org/packages/initphp/database) [![PHP Version Require](http://poser.pugx.org/initphp/database/require/php)](https://packagist.org/packages/initphp/database)
66

7-
PHP has powerful database abstraction libraries like Doctrine and Laravel Eloquent which are pretty nice. However, these are too extensive and cumbersome for projects that only need to easily create and execute database queries. If you don't always need migrations and seeding, this library will do the trick.
8-
97
## Requirements
108

119
- PHP 7.4 and later.
@@ -125,10 +123,10 @@ $db->select('user.name as author_name', 'post.id', 'post.title')
125123
* ORDER BY post ASC, post.created_at DESC
126124
* LIMIT 20, 10
127125
*/
128-
$db->get(); // Install the SQL statement, execute, and reset the Query Builder.
129-
if ($db->numRows() > 0) {
130-
foreach ($db->rows() as $row) {
131-
echo $row->title . ' by ' . $row->author_name . '<br />';
126+
$res = $db->read();
127+
if($db->numRows() > 0){
128+
foreach ($res as $row) {
129+
echo $row['title'] . ' by ' . $row['author_name'] . '<br />';
132130
}
133131
}
134132
```
@@ -188,9 +186,7 @@ The most basic example of a model class would look like this.
188186
```php
189187
namespace App\Model;
190188

191-
use \InitPHP\Database\Model;
192-
193-
class Posts extends Model
189+
class Posts extends \InitPHP\Database\Model
194190
{
195191

196192
/**
@@ -209,7 +205,7 @@ class Posts extends Model
209205
/**
210206
* If not specified, \InitPHP\Database\Entity::class is used by default.
211207
*
212-
* @var EntityInterface|string
208+
* @var \InitPHP\Database\Entity|string
213209
*/
214210
protected $entity = \App\Entities\PostEntity::class;
215211

@@ -311,8 +307,8 @@ class Posts extends Model
311307
protected bool $updatable = true;
312308

313309
protected array $validation = [
314-
'id' => 'is_unique|int', // Validation methods can be string separated by a perpendicular line.
315-
'title' => ['required', 'string'], // Validation methods can be given as an array.
310+
'id' => ['is_unique', 'int'],
311+
'title' => ['required', 'string', 'length(0,255)'],
316312
];
317313

318314
protected array $validationMsg = [
@@ -337,9 +333,7 @@ The most basic example of a entity class would look like this.
337333
```php
338334
namespace App\Entities;
339335

340-
use \InitPHP\Database\Entity;
341-
342-
class PostEntity extends Entity
336+
class PostEntity extends \InitPHP\Database\Entity
343337
{
344338
/**
345339
* An example of a getter method for the "post_title" column.

0 commit comments

Comments
 (0)