protected function initConnection() { $config = ORM::service('config'); $config->load(__DIR__ . '/bookstore/src/config/juborm.xml', 'production'); $config->set("models.bookstore.dir", "./bookstore/src/Model/Bookstore"); $this->dbDiffer('bookstore')->clean(); $this->dbDiffer('bookstore_clone')->clean(); }
<?php require_once __DIR__ . "/autoload.php"; use Juborm\ORM; use Bookstore\Model\Bookstore\Entities\Authors; use Bookstore\Model\Bookstore\Entities\AuthorsAddresses; use Bookstore\Model\Bookstore\Entities\Books; use Bookstore\Model\Bookstore\Entities\Dictionaries; $config = ORM::service('config'); $config->load(__DIR__ . '/../config/juborm.xml', 'production'); // simple select $select = Authors::select(); $result = $select->fetchAll(); $select->column("CONCAT(authors.first_name, ' ', authors.last_name)", 'fullName'); // building queries $select->equal('first_name', 'Matthew'); $select->like('last_name', 'Normani'); $select->startWith('last_name', 'N'); $select->endWith('last_name', 'i'); $select->contains('last_name', 'ma'); // author_id in(2) $select->in('author_id', array(2)); // this will be automaticly replace to "1=2" $select->in('author_id', array()); // use sub select as condition $subSelect = Authors::select('author_id'); $subSelect->in('author_id', array(2)); $select->in('author_id', $subSelect); // use expr to write complex condition $select->expr('author_id = :idA: OR author_id = :idB:'); $select->bind('idA', 1);
protected function execute(InputInterface $input, OutputInterface $output) { $config = $input->getOption('config'); $env = $input->getOption('env'); ORM::service('config')->load(realpath($config), $env); }