TP

  1. //'配置项'=>'配置值'  
  2.     'DB_TYPE'=>'mysql',   //新版本必须加上这个  
  3.     'DB_HOST' => '127.0.0.1',  
  4.     'DB_USER' => 'root',  
  5.     'DB_PWD' => '123',  
  6.     'DB_NAME' => 'weibo',  
  7.         'DB_PREFIX' =>'wei_'//表前缀  

一、实例化

D(tablename/modelname);
M(tablename);


    简单说使用M 方法的话,是不需要定义对应的模型类的(即使有
定义也不会读取),通常这样的模型仅能调用一些系统基础模型类
Model类里面的一些方法。
    使用D方法实例化模型的话,必须有对应的模型类文件,可以调用
一些模型自定义的方法或者属性,另外在Mode对应文件里面有自动
验证或者函数之类的业务逻辑也必需用D。

  1. $db = D('tablename/modelname'); //modelname一定要存在  
  2. $db = M('tablename');  

二、创建数据:

  1. $data = array(  
  2.    field1,value1,  
  3.    field2,value2,  
  4.    ...);  

两种数据创建方式

1. create方法

如果不传递data参数,默认提取post数据(注意post字段名与数据库一致)
  1. $db->create($data);  

数据的过滤:
①字段过滤
如果要只要提交部分字段,则可以在提交之前添加field过滤
  1. $db->field('name,email')->create();  
//只会提交属性为name和email部分的数据

②函数过滤
  1. $db->field('name,email')->create()->filter('strip_tags');  
  2. //filter是数据处理的函数  

2. data方法

设置数据,但不会去匹配字段名 也不会过滤字段,
如果为空,不会默认提交post数据 ,直接返回空
  1. $db->data($data);  

当然,我们可以在设置插入或更新的时候设置字段也可以
使用下面的方法

  1. namespace Home\Model;  
  2. use Think\Model;  
  3. class UserModel extends Model{  
  4.     protected $insertFields = 'name,email'// 新增数据的时候允许写入name和email字段    protected   
  5.     $updateFields = 'email'// 编辑数据的时候只允许写入email字段  
  6. }  

三、数据的写入

1. add方法

  1. //如果之前调用过create或data方法 ,则不需要传递$data参数  
  2. //第二个参数是条件子句,一般在前面用where函数过滤 不需要传递  
  3. //第三个参数是 是否覆盖原有数据  
  4. add($data='',$options=array(),$replace=false);  

2.addAll方法

  1. addA($dataList,$options=array(),$replace=false)  
  2. //跟add方法差不多,但是一次插入多条数据 是个二维数组  

四、数据读取

1、对应sql语句的函数操作

①alias 用于给当前数据表定义别名 字符串 
  1. SELECT * FROM think_user a INNER JOIN think_dept b ON b.user_id= a.id  
  2. $Model = M('User');  
  3. $Model->alias('a')->join('__DEPT__ b ON b.user_id= a.id')->select();  

②group 用于对查询的group支持 字符串 
  1. SELECT username,max(score) FROM think_score GROUP BY user_id,test_time  
  2. $this->field('username,max(score)')->group('user_id,test_time')->select();  

③having 用于对查询的having支持 字符串 
  1. SELECT username,max(score) FROM think_score GROUP BY user_id HAVING count(test_time)>3  
  2. $this->field('username,max(score)')->group('user_id')->having('count(test_time)>3')->select();   

④join 用于对查询的join支持 字符串和数组(可用多次连接) 

INNER JOIN: 如果表中有至少一个匹配,则返回行,等同于 JOIN 
LEFT JOIN: 即使右表中没有匹配,也从左表返回所有的行 
RIGHT JOIN: 即使左表中没有匹配,也从右表返回所有的行 
FULL JOIN: 只要其中一个表中存在匹配,就返回行 

  1. select * from think_artist   
  2. right join think_work  
  3. on think_artist.id = think_work.artist_id  
  4.   
  5. $Model = M('Artist');  
  6. //__WORK__和 __CARD__在最终解析的时候会转换为 think_work和 think_card  
  7. $Model->join('RIGHT JOIN __WORK__ ON __ARTIST__.id = __WORK__.artist_id')->select();  
  8. //或者使用:  
  9. $Model->join('__WORK__ ON __artist__.id = __WORK__.artist_id','RIGHT')->select();  
  10. //join方法的第二个参数支持的类型包括:INNER LEFT RIGHT FULL。  

⑤union 用于对查询的union支持 字符串、数组和对象 
UNION 操作符用于合并两个或多个 SELECT 语句的结果集
union 重复时不会记录进来
union all 重复时也会记录
  1. select name from think_user_0  
  2. union  
  3. select name from think_user_1  
  4. union  
  5. select name from think_user_2  
  6.   
  7. $Model->field('name')        
  8.    ->table('think_user_0')        
  9.    ->union(array('field'=>'name','table'=>'think_user_1'))        
  10.    ->union(array('field'=>'name','table'=>'think_user_2'))        
  11.    ->select();  

⑥distinct 用于查询的distinct支持 布尔值
  1. SELECT DISTINCT name FROM think_user  
  2. $Model->distinct(true)->field('name')->select();  

⑦order 用于对结果排序 字符串和数组 
  1. select * from userinfo   
  2. where status=1  
  3. order by id desc,status asc  
  4. limit 5  
  5.   
  6. $Model = M('userinfo');  
  7. $Model->where('status=1')  
  8.   ->order('id desc,status'//id desc ,status asc  
  9.   ->limit(5)->select();  

2. 函数操作的一般链式顺序(推荐,由于组合sql随意,

         所以只要保证查询函数之前调用就可以了)
->table()->alias()->distinct()
->field()->filter()->join()
->where()->union()->group()
->having()->order()->limit()/->page()

最后就是add/save/find/select

3. 数据读取的方法

①find方法 (返回一维数组)
  1. find($options=array()) //查询所有符合条件的记录的第一条记录  

②select方法 (返回二维数组)
  1. select($options=array()) //查询所有符合条件的记录  

③getField 读取某个列的多个或者单个数据
  1. getField($field,$sepa=null)  
  2. //$field字段名,可以是多个  
  3. $list = $User->getField('id,nickname');  

4. 数据直接查询

  1. query($sql,$parse=false)   //查询  
  2. execute($sql,$parse=false) //执行  

5. 记录统计

  1. $total = count($res);  

五、数据的更改

1.save方法

  1. save($data='',$options=array())  
  2. //同add一样,如果在save之前调用过data或create方法  
  3. //那么$data方法不用传递  
  4.   
  5. //如果$data中包含主键,那么where可以忽略  
  6. //否则如果忽略where的话,将不会更新任何数据  

2. setField方法

  1. setField($field,$value='')  
  2. //第一个参数可以是数组$data  
  3. //该函数会自动调用上面的save方法  

3.setInc和setDec方法。

  1. setInc($field,$step=1) //字段自增$step  
  2. setDec($field,$step=1) //字段自减$step  

六、数据的删除

delete方法

  1. delete($options=array())  
  2. //如果指定删除id,可以传入参数  
  3. $User->delete('1,2,5'); // 删除主键为1,2和5的用户数据  
  4. //不传入参数我们可以通过where函数判断  

六、调试

数据库调试函数:

1. 打印最后一条sql语句

  1. M("member")->getLastSql();  

2. 显示所有的sql语句

添加配置项
  1. 'SHOW_PAGE_TRACE'=>true,//配置项  
  2.     $db->show(''); //调用函数  








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
TP2915 is a video D/A solution for converting HD digital video signal into the analog domain that is suitable for transmission over single coaxial or twist-pair cable over long reach. The major application is the Automotive interconnect between HD display and HD camera systems or any other applications require robust and low cost transmission of HD video. TP2915 generates the analog video signal complying with HD Transport Video Interface (HD-TVI) format. It is one form of the HD composite video format that is widely adopted in the industry. TP2915 can support a variety of video resolution digital video input standards in 422 or 444 formats over 8, 16 or 24-bit interface with the embedded synchronization (EAV/SAV) header or explicit sync signals. It also accepts 24-bit RGB input with external sync signals. It has the built-in sync extraction logic to obtain the sync information inside the video stream. The video resolutions supported range from SD (NT/PAL) to UHD. TP2915 contains a versatile video timing generator that is programmable for all standards supported and other non-standard video formats. It has programmable clip/shift/scale function to proper condition the input video signal for further processing. It also has an optional 2x over-sampling filters built-in to support higher output sample rate. Over-sampling can relax the external analog filter requirement. TP2915 supports selectable current mode and voltage mode output as well as internal programmable analog reconstruction filter. The built-in data slicer help minimize glue circuits. The signal amplitude of the DAC output can be set by external current setting resistor. It also has built-in color bar test pattern generator for easy testing and adjustment. TP2915 has built-in clock jitter reduction circuit based on local crystal clock to ensure the output signal performance.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值