自动构建数据库模式
包含两个过程,构建数据库的对象-关系映射,和从example数据库user表中自动创建一个类.在表中的所有字段
名将成为类成员变量.
创建适当的模式:
C:\PHP\PEAR\DB\DataObject>C:\PHP\php.exe createTables.php \ C:\dataobjects\example.ini
这将生成User.php文件:
<?php /** * Table Definition for user * www.knowsky.com */ require_once 'DB/DataObject.php';
class DataObjects_User extends DB_DataObject { ###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */ var $__table = 'user'; // table name var $user_Id; // int(11) not_null primary_key auto_increment var $first_Name; // string(30) not_null var $last_Name; // string(40) not_null var $email; // string(100) not_null
/* Static get */ function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_User',$k,$v); }
/* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE } ?>
它还会为user表模式生成example.ini配置文件:
[user] user_Id = 129 first_Name = 130 last_Name = 130 email = 130
[user__keys] user_Id = N
Smarty files It's time to create several files for Smarty:
Smarty文件 现在是创建几个Smarty文件的时候了:
include.php 1 <? 2 require('Smarty.class.php'); 3 $smarty = new Smarty; 4 $smarty->template_dir = 'templates/'; 5 $smarty->compile_dir = 'templates_c/'; 6 $smarty->config_dir = 'configs/'; 7 $smarty->cache_dir = 'cache/'; ?>
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页
|