手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2012年04月的文章

php freetds 处理sqlserver大字段的问题

freetds连接sqlserver是没问题,在连接的时候dsn用的是dblib,而不是mssql。
连接和普通的查询都没有问题,但一旦涉及到大字段,你就会发现问题多多了。比如你的字段类型是nvarchar(max),你在处理的时候你会发现,返回结果都是空。
我晶啊。看来php连接sqlserver还是用windows自己的方案吧:sqlsrv这个组件,但它只能在windows下面使用。

太纠结了

Tags: freetds, sqlserver, 大字段

yii 连接 mssql遇到的一些问题

1、yii在linux下面连接mssql时,connectString一般是dblib:xxxxx,而不是mssql,这是因为用freetds的原因
2、用gii生成mssql的数据表结构时,如果表的字段是类似"Post Time"(即,字段中间有空格),则直接会报错
3、当生成好Model时,使用xxx::model()->findAll()时,如果最初的表结构里有允许某个字段为空,即允许isnull的话,在数据库中,该字段无值时是NULL,findAll就会报错:

XML/HTML代码
  1. CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 4004 General SQL Server error: Check messages from the SQL Server [4004] (severity 16) [(null)]. The SQL statement executed was: SELECT TOP 1 * FROM [dbo].[DatabaseLog] [t]  

4、无论是mysql还是sqlserver,当在components中设置columnCase值的时候,都会报错,这是因为在 MysqlSchema中都是采用了大小写敏感的方式(如$column['IsIdenfy'])之类的,当大小写敏感后,如果在attributes 中设置了PDO的ATTR_CASE,都会报错

Tags: yii, mssql

随便说说

其实本不想说什么,但是觉得很意外,所以我还是说说了。
一两句而已:
经过某便利店买了瓶啤酒,在收银的时候,一个大妈笑着对我说,送你一个上网软件,扫了一下光盘上的字,立刻就明白了是什么样的软件(XX门,你懂的)。于是我说不需要,我也不想举报你啥的。大妈说,人总要听听外面的声音才是。
我震精了。
---------
现在某些一块、5块的纸币上面多了一些印刷体,委实让人痛苦,扔了吧,可惜,不扔吧,又要传播。TMD,这算是一个什么样的世道??或许你真的有理,但你这样做,就真的没理。

---------
牢骚发完了,继续折腾

yii:Apache and Nginx configurations

yii的urlmanager可以让项目在访问的时候隐藏index.php,也可以以更优雅的urlrewrite方式来显示,但这一切需要一些配置,在apache上的配置上就相对比较简单,直接参考wordpress的官方配置就完了,但其实很久以来,一直都没有人写过nginx下的配置。大家都是在根据wordpress配置来更改的,比如lnmp项目中,就是:

XML/HTML代码
  1. location / {  
  2. if (-f $request_filename/index.html){  
  3.                 rewrite (.*) $1/index.html break;  
  4.         }  
  5. if (-f $request_filename/index.php){  
  6.                 rewrite (.*) $1/index.php;  
  7.         }  
  8. if (!-f $request_filename){  
  9.                 rewrite (.*) /index.php;  
  10.         }  
  11. }  

不过,这两天在看官方guide的文档,原来这些问题,官方已经提供方案了:http://yii.neatcn.com/doc/guide/1.1/en/quickstart.apache-nginx-config#nginx

1. Apache

Yii is ready to work with a default Apache web server configuration. The .htaccess files in Yii framework and application folders restrict access to the restricted resources. To hide the bootstrap file (usually index.php) in your URLs you can add mod_rewrite instructons to the .htaccess file in your document root or to the virtual host configuration:

XML/HTML代码
  1. RewriteEngine on  
  2.   
  3. # if a directory or a file exists, use it directly  
  4. RewriteCond %{REQUEST_FILENAME} !-f  
  5. RewriteCond %{REQUEST_FILENAME} !-d  
  6. # otherwise forward it to index.php  
  7. RewriteRule . index.php 

2. Nginx

You can use Yii with Nginx and PHP with FPM SAPI. Here is a sample host configuration. It defines the bootstrap file and makes yii catch all requests to unexisting files, which allows us to have nice-looking URLs.

XML/HTML代码
  1. server {  
  2.     set $host_path "/www/mysite";  
  3.     access_log  /www/mysite/log/access.log  main;  
  4.   
  5.     server_name  mysite;  
  6.     root   $host_path/htdocs;  
  7.     set $yii_bootstrap "index.php";  
  8.   
  9.     charset utf-8;  
  10.   
  11.     location / {  
  12.         index  index.html $yii_bootstrap;  
  13.         try_files $uri $uri/ $yii_bootstrap?$args;  
  14.     }  
  15.   
  16.     location ~ ^/(protected|framework|themes/\w+/views) {  
  17.         deny  all;  
  18.     }  
  19.   
  20.     #avoid processing of calls to unexisting static files by yii  
  21.     location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {  
  22.         try_files $uri =404;  
  23.     }  
  24.   
  25.     # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
  26.     #  
  27.     location ~ \.php {  
  28.         fastcgi_split_path_info  ^(.+\.php)(.*)$;  
  29.   
  30.         #let yii catch the calls to unexising PHP files  
  31.         set $fsn /$yii_bootstrap;  
  32.         if (-f $document_root$fastcgi_script_name){  
  33.             set $fsn $fastcgi_script_name;  
  34.         }  
  35.   
  36.         fastcgi_pass   127.0.0.1:9000;  
  37.         include fastcgi_params;  
  38.         fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;  
  39.   
  40.         #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI  
  41.         fastcgi_param  PATH_INFO        $fastcgi_path_info;  
  42.         fastcgi_param  PATH_TRANSLATED  $document_root$fsn;  
  43.     }  
  44.   
  45.     location ~ /\.ht {  
  46.         deny  all;  
  47.     }  
  48. }  

Using this configuration you can set cgi.fix_pathinfo=0 in php.ini to avoid many unnesessary system stat() calls.

Tags: yii, apache, nginx, wordpress, urlrewrite

Yii数据库迁移工具

其实早就想写这样的文章来介绍这个玩意,不过一来项目中没有用到这个东西,二来官方的文档也是英文的,自己也没有仔细看就没有介绍。
官方的文档其实写的很详细了,不过因为真没用到它,也就没有发言权。
不过这两天在闲逛 ,倒是看到了一些文章:

  1. 小试Yii框架下的数据迁移功能
  2. yiichina的中文版介绍 :http://www.yiichina.com/api/CDbMigration
  3. 官方的手册:http://www.yiiframework.com/doc/guide/1.1/en/database.migration

这些文章还是可以看看的,关键问题是这些配置改了之后,难道会自动更新model文件吗?哎。

Tags: yii, migrate

Records:3812345678