$memo = new DTable('{{memo}}');
$memo->msg = 'this is content';
$memo->save();
//last insertid
echo $memo->id ;
$memo = DTable::model('{{memo}}')->findByPk(12);
$memo->msg = "modefid content";
$memo->save();
//使用非默认数据库,需要在 config/main.php 文件中定义数据库连接,如:
'components' => array(
'db-other'=>array(
'class' => 'CDbConnection',
'connectionString' => 'mysql:host=localhost;dbname=cdcol;charset=utf8',
'username' => 'root',
'password' =>'',
'tablePrefix' => '',
'autoConnect' => false,
),
);
DTable::$db = Yii::app()->getComponent('db-other');
$memo = DTable::model('{{memo}}')->findByPk(12);
/**
* DTable class file.
* @author zhangxugg@163.com
* @since Yii 1.1.10
* @package application.models
* @version $Id DTable.php 1 2012-03-24 23:29 $
DTable provides dynamic table model supports for some application entironment such as dynamic-generated database tables, or simple read actions.
please contact zhangxugg@163.com for the source code.
new record :
$model = new DTable('table_name');
//use table prefix:
$model = new DTable('{{table_name}}');
$model->id = $id;
$model->name = 'zhangxugg@163.com';
$model->save();
update:
$model = DTable::model('{{table_name}}')
$model->name = 'zhangxugg@163.com'
$model->save();
$list = $model->findAll();
use non-default database connection :
DTable::$db = Yii::app()->getCompoments('db-extra');
tips : you must define the database connection informations in config/main.php
'components' => array(
'db-extra' => array(
'class' => 'CDbConnection',
'connectionString' => 'mysql:host=localhost;dbname=cdcol;charset=utf8',
'username' => 'root',
'password' =>'',
'tablePrefix' => '',
'autoConnect' => false,
),
)
DTable source code :
class DTable extends CActiveRecord {
private static $tableName ;
public function __construct($table_name = '') {
if($table_name === null) {
parent::__construct(null);
} else {
self::$tableName = $table_name ;
parent::__construct();
}
}
public static function model($table_name='')
{
self::$tableName = $table_name ;
return parent::model(__CLASS__);
}
public function tableName()
{
return self::$tableName;
}
}
*/
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有