Skip to content

Instantly share code, notes, and snippets.

{
"id":10,
"firstname":"test1",
"lastname":"test2",
"age":20
}
// オートローダー設定
$loader = new Phalcon\Loader();
$loader->registerNamespaces(
[
'App\Models' => __DIR__ . '/models/',
]
);
$loader->register();
// DB接続情報
$container = new Phalcon\Di\FactoryDefault();
$container->set(
'db',
function () {
return new Phalcon\Db\Adapter\Pdo\Postgresql(
[
'host' => 'localhost',
'port' => 5432,
'username' => 'postgres',
<?php
namespace App\Models;
use Phalcon\Validation;
class Empuser extends \Phalcon\Mvc\Model
{
public function validation()
{
// とりあえずこれだけ
$validator = new Validation();
}
$app
->modelsManager
->executeQuery(
'SELECT * FROM App\Models\Empuser WHERE id = :idxxxx: ',
[
'idxxxx' => $id
]);
echo json_encode($records);
C:.
├─models
└─index.php
create table "public".empuser (
id integer not null
, firstname character varying(60) not null
, lastname character varying(60) not null
, age integer not null
, primary key (id)
);
// add start
$app = new Micro();
$app->delete(
'/api/v2/getData',
function () {
$ret = [
'name' => 'yamada',
'id' => 20
];
echo json_encode($ret);
// add start
$app = new Micro();
$app->put(
'/api/v2/getData',
function () {
$ret = [
'name' => 'yamada',
'id' => 20
];
echo json_encode($ret);
// add start
$app = new Micro();
$app->post(
'/api/v2/getData',
function () {
$ret = [
'name' => 'yamada',
'id' => 20
];
echo json_encode($ret);