rhaco: データベース操作(insert)
project.xml
<project rhacover="1.6.1" version="0.0.1" name="rhaco_test" xmlns="http://rhaco.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rhaco.org http://m.rhaco.org/xsd/project_1_6_x.xsd"> <database name="rhaco"> <table name="items" admin="true"> <column name="id" type="serial" /> <column name="name" type="string" require="true" /> <column name="email" type="email" unique="true" require="true" /> <column name="body" type="string" unique="true" require="true" /> <column name="created" type="timestamp" default="sysdate" /> </table> </database> </project>
index.php
require('__init__.php'); Rhaco::import('database.DbUtil'); Rhaco::import('model.Items'); $db = new DbUtil(Items::connection()); $items = new Items(); $items->setName('Your Name'); $items->setEmail('yourname@hostname.com'); $items->setBody('This is body.'); $db->insert($items);