zend framework mysql_Zend Framework的缺陷(连载之1)

/* Author : Romain Boisnard */

/* Liscenced under the LGPL GNU Lesser General Public Liscence, report the actual liscence for details.

/* LinkedException */

// Java-like exception with a cause

class LinkedException extends Exception {

private $cause;

function __construct($_message = null, $_code = 0, Exception $_cause = null) {

parent::__construct($_message, $_code);

$this->cause = $_cause;

}

public function getCause() {

return $this->cause;

}

public function getStackTrace() {

if ($this->cause !== null) {

$arr = array();

$trace = $this->getTrace();

array_push($arr, $trace[0]);

unset($trace);

if (get_class($this->cause) == "LinkedException") {

foreach ($this->cause->getStackTrace() as $key => $trace) {

array_push($arr, $trace);

}

}

else {

foreach ($this->cause->getTrace() as $key => $trace) {

array_push($arr, $trace);

}

}

return $arr;

}

else {

return $this->getTrace();

}

}

public function showStackTrace() {

$htmldoc = "

An exception was thrown :";

$htmldoc.= "Exception code : $this->code
";

$htmldoc.= "Exception message : $this->message
";

$htmldoc.= "";

$i = 0;

foreach ($this->getStackTrace() as $key => $trace) {

$htmldoc.= $this->showTrace($trace, $i);

$i++;

}

$htmldoc.= "#$i {main}
";

unset($i);

$htmldoc.= "

";

return $htmldoc;

}

private function showTrace($_trace, $_i) {

$htmldoc = "#$_i ";

if (array_key_exists("file",$_trace)) {

$htmldoc.= $_trace["file"];

}

if (array_key_exists("line",$_trace)) {

$htmldoc.= "(".$_trace["line"]."): ";

}

if (array_key_exists("class",$_trace) && array_key_exists("type",$_trace)) {

$htmldoc.= $_trace["class"].$_trace["type"];

}

if (array_key_exists("function",$_trace)) {

$htmldoc.= $_trace["function"]."(";

if (array_key_exists("args",$_trace)) {

if (count($_trace["args"]) > 0) {

$args = $_trace["args"];

$type = gettype($args[0]);

$value = $args[0];

unset($args);

if ($type == "boolean") {

if ($value) {

$htmldoc.= "true";

}

else {

$htmldoc.= "false";

}

}

elseif ($type == "integer" || $type == "double") {

if (settype($value, "string")) {

if (strlen($value) <= 20) {

$htmldoc.= $value;

}

else {

$htmldoc.= substr($value,0,17)."...";

}

}

else {

if ($type == "integer" ) {

$htmldoc.= "? integer ?";

}

else {

$htmldoc.= "? double or float ?";

}

}

}

elseif ($type == "string") {

if (strlen($value) <= 18) {

$htmldoc.= "'$value'";

}

else {

$htmldoc.= "'".substr($value,0,15)."...'";

}

}

elseif ($type == "array") {

$htmldoc.= "Array";

}

elseif ($type == "object") {

$htmldoc.= "Object";

}

elseif ($type == "resource") {

$htmldoc.= "Resource";

}

elseif ($type == "NULL") {

$htmldoc.= "null";

}

elseif ($type == "unknown type") {

$htmldoc.= "? unknown type ?";

}

unset($type);

unset($value);

}

if (count($_trace["args"]) > 1) {

$htmldoc.= ",...";

}

}

$htmldoc.= ")
";

}

return $htmldoc;

}

}

2

1

分享到:

18e900b8666ce6f233d25ec02f95ee59.png

72dd548719f0ace4d5f9bca64e1d7715.png

2010-05-03 23:47

浏览 2950

评论

3 楼

rtxbc

2011-03-26

bardo 写道

zend framework有没有生成静态页面的方法

freedomstyle 写道

不知道zend framework有没有生成静态页面的方法

那是没有的。静态页面规则较为复杂。这方面倒现在没有统一的方案。

另一方面,zend不会推出,因为,它不会排斥官方的smarty,这个是能生成页面缓存的。

在controller类里面使用$html =  $this->view->render('xml/codec.xml') ;可以把渲染后的结果放入到$html里,然后你可以用file_put_content()或者其他文件操作方式,生成你所需要的文件.

2 楼

bardo

2010-05-26

zend framework有没有生成静态页面的方法

freedomstyle 写道

不知道zend framework有没有生成静态页面的方法

那是没有的。静态页面规则较为复杂。这方面倒现在没有统一的方案。

另一方面,zend不会推出,因为,它不会排斥官方的smarty,这个是能生成页面缓存的。

1 楼

freedomstyle

2010-05-24

不知道zend framework有没有生成静态页面的方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值