PHP code example of jakolab / howl-orm

1. Go to this page and download the library: Download jakolab/howl-orm 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/ */

    

jakolab / howl-orm example snippets


 
# This is your proyect root.

# Requiring Howl.
Autoload();

# Getting the Manager instance.
$db = \Howl\DBManager::getInstance();

$config = [
    'host' => 'localhost',
    'user' => 'root',
    'database' => 'your database',
    'password' => 'your password',
];

# Loading the desired driver.
$db->loadDriver(\Howl\DBManager::MYSQL_DRIVER, $config);


 
HowlAutoload::initAutoload();
$config = [
    'host' => 'localhost',
    'user' => 'root',
    'database' => 'your database',
    'password' => 'your password',
];
\Howl\DBManager::getInstance()->loadDriver(\Howl\DBManager::MYSQL_DRIVER, $config);


namespace Model;
use Howl\Model;

class Items extends Model{
  protected $table = "tbl_items";
}


 
# this is how we create a new record using Howl-ORM
$item = new \Model\Items();
$item->name = "This is the name";
$item->description = "Lorem ipsum dolor sit...";
$item->save();

$records = \Model\Items::search()->all();

$item = \Model\Items::search()->byPk(1);
$item->name = "Name updated...";
$item->save();

$item = \Model\Items::search()->byPk(1);
$item->delete();
# or
\Model\Items::search()->byPk(2)->delete();

$records = \Model\Items::search()
                        ->equals("field1", "item1")
                        ->and()
                        ->equals("field2", 2)
                        ->get();