FleaPHP报错。。。。。。。。。。。。
错误信息:
SQL 错误消息: "Unknown column 'blog_posts.post_id ' in 'field list'" SQL 语句: "SELECT `blog_posts`.`post_id ` AS flea_pkref_post_id , `blog_posts`.* FROM `blog_posts`" SQL 错误代码: "7335941".
错误原因:
您看到这个错误
页面是因为
应用程序抛出了没有捕获的异常。
异常的详细内容: exception 'FLEA_Db_Exception_SqlQuery' with message 'SQL 错误消息: "Unknown column 'blog_posts.post_id ' in 'field list'"
SQL 语句: "SELECT `blog_posts`.`post_id ` AS flea_pkref_post_id , `blog_posts`.*
FROM `blog_posts`"
SQL 错误代码: "7335941".' in D:\usr\www\localhost\public_html\testFleaphp\FLEA\FLEA\Db\Driver\Mysql.php:226
Stack trace:
#0 D:\usr\www\localhost\public_html\testFleaphp\FLEA\FLEA\Db\TableDataGateway.php(697): FLEA_Db_Driver_Mysql->execute('SELECT `blog_po...')
#1 D:\usr\www\localhost\public_html\testFleaphp\index.php(31): FLEA_Db_TableDataGateway->findAll()
#2 {main}
Exception: FLEA_Db_Exception_SqlQuery
Message: SQL 错误消息: "Unknown column 'blog_posts.post_id ' in 'field list'" SQL 语句: "SELECT `blog_posts`.`post_id ` AS flea_pkref_post_id , `blog_posts`.* FROM `blog_posts`" SQL 错误代码: "7335941".
Filename: D:\usr\www\localhost\public_html\testFleaphp\FLEA\FLEA\Db\TableDataGateway.php
#2 FLEA_Db_Driver_Mysql::execute('SELECT `blog_posts`.`post_i ...')
FILE: TableDataGateway.php
LINE: 697
ARGS:
复制内容到剪贴板
代码:
Array
(
[0] => SELECT `blog_posts`.`post_id ` AS flea_pkref_post_id , `blog_posts`.*
FROM `blog_posts`
)复制内容到剪贴板
代码:
687 // 当有关联需要处理时,必须获得主表的主键字段值
688 $sql = "SELECT {$this->qpka}, {$fields}\nFROM {$this->qtableName}{$sqljoin}{$whereby}{$sortby}";
689 } else {
690 $sql = "SELECT {$fields}\nFROM {$this->qtableName}{$whereby}{$sortby}";
691 }
692
693 // 根据 $length 和 $offset 参数决定是否使用限定结果集的查询
694 if (null !== $length || null !== $offset) {
695 $result = $this->dbo->selectLimit($sql, $length, $offset);
696 } else {
697 $result = $this->dbo->execute($sql);
698 }
699
700 if ($enableLinks) {
701 /**
702 * 查询时同时将主键值单独提取出来,
703 * 并且准备一个以主键值为键名的二维数组用于关联数据的装配
704 */
705 $pkvs = array();
706 $assocRowset = null;
707 $rowset = $this->dbo->getAllWithFieldRefs($result,Filename: D:\usr\www\localhost\public_html\testFleaphp\index.php
#1 FLEA_Db_TableDataGateway::findAll()
复制内容到剪贴板
代码:
<?php
require("FlEA/FLEA.php");
FLEA::setAppInf("internalCacheDir",dirname(__FILE__).'/Cache');
$dsn=array(
'driver' => 'mysql',
'host' => 'localhost',
'login' => 'root',
'password' => 'root',
'database' => 'blog',
);
FLEA::setAppInf('dbDSN',$dsn);
FLEA::loadClass('FLEA_Db_TableDataGateway');
class Table_Posts extends FLEA_Db_TableDataGateway
{
var $tableName='blog_posts';
var $primaryKey='post_id ';
var $hasMany=array(
array(
'tableClass' => 'Table_Comment',
'foreignKey' => 'post_id',
'mappingName' => 'comments'
),
);
}
class Table_Comment extends FLEA_Db_TableDataGateway
{
var $tableName='blog_comments';
var $primaryKey='comment_id';
}
$table_psot=& new Table_Posts();
$rowset=$table_psot->findAll();
dump($rowset);
?>