This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id":10, | |
"firstname":"test1", | |
"lastname":"test2", | |
"age":20 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// オートローダー設定 | |
$loader = new Phalcon\Loader(); | |
$loader->registerNamespaces( | |
[ | |
'App\Models' => __DIR__ . '/models/', | |
] | |
); | |
$loader->register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DB接続情報 | |
$container = new Phalcon\Di\FactoryDefault(); | |
$container->set( | |
'db', | |
function () { | |
return new Phalcon\Db\Adapter\Pdo\Postgresql( | |
[ | |
'host' => 'localhost', | |
'port' => 5432, | |
'username' => 'postgres', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use Phalcon\Validation; | |
class Empuser extends \Phalcon\Mvc\Model | |
{ | |
public function validation() | |
{ | |
// とりあえずこれだけ | |
$validator = new Validation(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$app | |
->modelsManager | |
->executeQuery( | |
'SELECT * FROM App\Models\Empuser WHERE id = :idxxxx: ', | |
[ | |
'idxxxx' => $id | |
]); | |
echo json_encode($records); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:. | |
├─models | |
└─index.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add start | |
$app = new Micro(); | |
$app->delete( | |
'/api/v2/getData', | |
function () { | |
$ret = [ | |
'name' => 'yamada', | |
'id' => 20 | |
]; | |
echo json_encode($ret); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add start | |
$app = new Micro(); | |
$app->put( | |
'/api/v2/getData', | |
function () { | |
$ret = [ | |
'name' => 'yamada', | |
'id' => 20 | |
]; | |
echo json_encode($ret); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// add start | |
$app = new Micro(); | |
$app->post( | |
'/api/v2/getData', | |
function () { | |
$ret = [ | |
'name' => 'yamada', | |
'id' => 20 | |
]; | |
echo json_encode($ret); |