php7查看数据表,php – Drupal 7 – 自定义查看与自定义表,没有数据显示

我写了一个模块来使用Drupal 7与Views 3进行接口,但是当我使用自定义表格作为数据源创建一个视图时,没有数据显示.这是

MySQL的架构

+-------------+------------+------+-----+---------+----------------+

| Field | Type | Null | Key | Default | Extra |

+-------------+------------+------+-----+---------+----------------+

| id | int(11) | NO | PRI | NULL | auto_increment |

| title | mediumtext | NO | | NULL | |

| Department | text | NO | | NULL | |

| credits | int(10) | NO | | NULL | |

| description | longtext | NO | | NULL | |

+-------------+------------+------+-----+---------+----------------+

这是my_module.views.inc中的钩子覆盖:

function my_module_views_data() {

$tableName = 'My_Awesome_Table';

$data = array();

$data[$tableName]['table']['group'] = t('Courses');

$data[$tableName]['table']['base'] = array(

'field' => 'id',

'title' => t('Courses'),

'help' => t("Contains courses, departments, and descriptions.")

);

$data[$tableName]['title'] = array(

'title' => t('Course name'),

'help' => t('Course name'),

'field' => array(

'handler' => 'views_handler_field',

'click sortable' => TRUE,

),

'sort' => array(

'handler' => 'views_handler_sort',

),

'filter' => array(

'handler' => 'views_handler_filter_string',

),

'argument' => array(

'handler' => 'views_handler_argument_string',

),

);

$data[$tableName]['Department'] = array(

'title' => t('Course department'),

'help' => t('Course department'),

'field' => array(

'handler' => 'views_handler_field',

'click sortable' => TRUE,

),

'sort' => array(

'handler' => 'views_handler_sort',

),

'filter' => array(

'handler' => 'views_handler_filter_string',

),

'argument' => array(

'handler' => 'views_handler_argument_string',

),

);

$data[$tableName]['credits'] = array(

'title' => t('Credits'),

'help' => t('Number of credit hours'),

'field' => array(

'handler' => 'views_handler_field',

'click sortable' => TRUE,

),

'argument' => array('handler' => 'views_handler_argument_numeric'),

'filter' => array('handler' => 'views_handler_filter_numeric'),

'sort' => array('handler' => 'views_handler_sort_numeric')

);

$data[$tableName]['description'] = array(

'title' => t('Course description'),

'help' => t('Course description'),

'field' => array(

'handler' => 'views_handler_field',

'click sortable' => TRUE,

),

'sort' => array(

'handler' => 'views_handler_sort',

),

'filter' => array(

'handler' => 'views_handler_filter_string',

),

'argument' => array(

'handler' => 'views_handler_argument_string',

),

);

$data[$tableName]['id'] = array(

'title' => t('Unique identifier'),

'help' => t('Primary key for table'),

'field' => array('handler' => 'views_handler_field'),

'argument' => array('handler' => 'views_handler_argument_numeric'),

'filter' => array('handler' => 'views_handler_filter_numeric'),

'sort' => array('handler' => 'views_handler_sort_numeric'));

return $data;

}

我的映射有什么问题吗?当我创建一个视图时,我正在尝试一个简单的无格式列表,并只显示每个字段的标签.显示数据的唯一字段是id,我表中的所有id值都在那里.我尝试向视图添加过滤器,以便课程部门!=空白和课程名称!=空白,这不会消除任何结果(基于显示的ids).这是查询视图正在生成:

SELECT My_Awesome_Table.title AS My_Awesome_Table_title,

My_Awesome_Table.Department AS My_Awesome_Table_Department,

My_Awesome_Table.description AS My_Awesome_Table_description,

My_Awesome_Table.credits AS My_Awesome_Table_credits,

My_Awesome_Table.id AS id

FROM {My_Awesome_Table} My_Awesome_Table

WHERE (( (My_Awesome_Table.Department NOT LIKE '' ESCAPE '\\') AND

(My_Awesome_Table.title NOT LIKE '' ESCAPE '\\') ))

当我在phpMyAdmin中运行它时,只需从My_Awesome_Table周围删除{和},它返回结果,每列中都有数据.

编辑:这可能与我在另一个数据库中为另一个表另外创建了一个自定义View模块相关联,它的工作正常.我使用该模块作为这个模块的基础,更改模块名称,函数前缀等.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值