$accounts = new Accounts;
$accounts->login = 'test';
$accounts->password = 'ABCDEF';
$accounts->steam_guard = '0';
$accounts->worker_id = '1';
if ($accounts->save() === false) {
$messages = $accounts->getMessages();
foreach ($messages as $message) {
echo $message, "\n";
}
}
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(
[
'App\\Models' => __DIR__ . '/models/',
]
);
$loader->registerDirs(
[
...
__DIR__ . '/models/',
...
]
)->register();
namespace App\Models;
class Accounts extends \Phalcon\Mvc\Model {
public $id;
public $login;
public $password;
public $steam_guard;
public $email;
public $worker_id;
}
use App\Models\Accounts;
class AdminController extends \Phalcon\Mvc\Controller {
public function getAccounts() {
$accounts = Accounts::find();
return $this->response->setJsonContent(['accounts' => $accounts])->send();
}
}
<form action="" method="post">
<input type="number" required name="min">
<input type="number" required name="max">
<input type="submit" name="submit">
<p>
<?php
if (isset($_POST['submit'])) {
$min = intval($_POST['min']);
$max = intval($_POST['max']);
$n = rand($min , $max);
echo $n;
}
?>
</p>
$router = $di->getRouter(FALSE);
//$router = Phalcon\Mvc\Router(FALSE);
...
...
$router->notFound([
'controller' => 'index',
'action' => 'route404'
]);
...
class IndexController extends ControllerBase
{
public function route404Action()
{
$this->view->disable();
$this->response->setRawHeader('HTTP/1.1 404 Not Found');
$this->response->setContent('<b>404, bratishka :(</b>');
$this->response->send();
}
}