- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在使用 Grocery Crud开发一个简单的本地应用程序,允许用户自己注册并喜欢乐队并对其进行评分,并选择他们认识的也在该应用程序中注册的人。
实体:
Person(person_id,person_URL, fullname, hometown)
乐队(band_id,band_URL,band_name,country,genre)
关系:
喜欢(person_id,band_id,rate)
知道(person_id,known_person_id)
我的问题是:
1) 我想返回一张人物和已知人物的表格,如下所示:
KNOWS
person_id | fullname | known_person_id | known_fullname<br/>
但我不能使用 *set_relation_n_n* 函数,因为关系是 (Person -> Likes -> Person),所以它给我错误。我想出的另一个解决方案是制作一个自定义表,进行查询以返回我想要的值并将其显示在表中(下面的代码)。返回的自定义表是正确的,但是当我将它渲染到我的 Grocery Crud 表时,我需要指定 $crud->columns('person_id', 'fullname', 'known_person_id', 'fullname'),它无法区分全名人名和已知人的全名。我该怎么做才能以这种方式显示表格?
2) 我在另一个表中遇到了同样的问题,但可以使用函数 *set_relation_n_n* 来解决这个问题,因为它是一种关系(Person -> Likes -> Band),所以因为它是 2 个不同的实体它没有给我返回错误。问题是查询(下面的代码)向我返回了整个表格,而我每页只需要 25 条记录。当我尝试在查询中使用“LIMIT 25”时,它只返回 25 条记录并且“下一页”按钮不起作用。有什么解决办法吗?
下面,所有信息:
问题 1 的代码:
function knows_management()
{
$crud = new grocery_CRUD();
$crud->set_model('model_socialnetwork');
$crud->set_table('knows');
$crud->set_subject('Known');
$crud->basic_model->set_query_str('SELECT tb1.person_id, tb1.fullname, tb1.known_person_id, person.fullname FROM (SELECT person.person_id, person.fullname, knows.known_person_id FROM person INNER JOIN knows ON person.person_id = knows.person_id) tb1 INNER JOIN person ON tb1.known_person_id = person.person_id');<br>
$crud->columns('person_id','fullname','known_person_id','fullname');
$output = $crud->render();
$this->_socialnetwork_output($output);
}
问题 2 的代码:
function likes_management()
{
$crud = new grocery_CRUD();
$crud->set_model('model_socialnetwork');
$crud->set_table('likes');
$crud->set_subject('Like');
$crud->columns('person_id','fullname','band_id','band_name', 'rate');
$crud->basic_model->set_query_str('SELECT tb2.person_id, tb2.fullname, tb2.band_id, band.band_name, tb2.rate FROM(SELECT tb1.person_id, person.fullname, tb1.band_id, tb1.rate FROM(SELECT person.person_id, likes.band_id, likes.rate FROM person INNER JOIN likes ON person.person_id = likes.person_id) tb1 INNER JOIN person ON tb1.person_id = person.person_id) tb2 INNER JOIN band ON tb2.band_id = band.band_id');
$output = $crud->render();
$this->_socialnetwork_output($output);
}
最佳答案
问题 1) 例如,如果您在查询中使用别名会怎样
选择 tb1.person_id、tb1.fullname 作为 Tb1fullName、tb1.known_person_id、person.fullname 作为 PersonFullName
问题 2) 我不建议您在查询中直接/手动添加 LIMIT。在文件 application/config/grocery_crud.php 中,您有两个与分页直接相关的选项
您应该正确使用和配置它们
// The default per page when a user firstly see a list page
$config['grocery_crud_default_per_page'] = 25;
....
//Having some options at the list paging. This is the default one that all the websites are using.
//Make sure that the number of grocery_crud_default_per_page variable is included to this array.
$config['grocery_crud_paging_options'] = array('10','25','50','100');
关于php - Grocery Crud - 无法区分返回查询表中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22966298/
我的想法是,当我添加一个新行时,其中一个字段 (ID) 必须具有默认值 + 另一个字段的值 + 日期。 ID 示例:IDPeter17112017 所以,这是我的代码,但它不起作用,或者可能不是最好的
我对 Grocery Grocery 很陌生。我在 insert_before_callback 上遇到了一些逻辑操作问题 我有一个产品表,当我出售产品时,它会检查产品的可用性。如果可用,则会将其插入
我正在尝试使用 callback_column 更改列值功能。 $crud = new grocery_CRUD(); $crud -> set_table('booking'); //$crud->
我在 GroceryCrud 中有一个问题。 我想在一张表中插入数据。表是这样的: id, card_no, site_code, site_no card_no 是独一无二的,我已经实现了它。 然而
我一直在使用 Grocery Crud开发一个简单的本地应用程序,允许用户自己注册并喜欢乐队并对其进行评分,并选择他们认识的也在该应用程序中注册的人。 实体: Person(person_id,per
我在 Mysql 中用这些列创建了一个表 secretNumber(主键和 AI) 姓名 日期 等... 我的想法是当我要向这个表中添加一个新项目时,自动生成一个“ secret 数字”但必须有 3
我是 Grocery CRUD 新手。这个库节省的时间给我留下了深刻的印象,我要感谢所有参与这个项目的优秀开发人员。 我在显示表中的日期字段时遇到一个小问题。当我按下编辑按钮时,它会显示在编辑和查看页
我在上传视频文件时遇到食品 Grocery 问题。在上传过程中显示过程图像,完成后显示空白,视频文件未上传。我已经为我的上传文件夹设置了 777 权限,我尝试上传 mp4、flv、3gp 文件格式。
需要一些帮助来建立产品和数量之间的关系。 Table1: Products Columns: id , code, unit, name, size , cost , price - Table2:
我是 Grocery 店的新手, 我不知道如何在不刷新页面的情况下重新加载 Grocery 网格。 目前我已经用ajax重新加载了所有页面 $.ajax({ type:'POS
在 grocery crud 中,不会搜索相关表。 仅针对该表字段进行搜索。 function index() { $crud = new grocery_CRUD(); $crud
您好,我正在将 Grocery CRUD 与 HMVC 结合使用,但我遇到了一些奇怪的问题。 class Source extends MX_Controller { function __c
在 Codeigniter 中通过 Grocery CRUD 库使用搜索查询时,在表中搜索数据的“0”值会得到完整的表。为什么? $crud = new grocery_CRUD();
我的 Controller ,在 invHdrData 表中插入一行,我希望该表中的最大文档编号自动插入文档编号插入之前的回调不起作用。那么问题出在哪里呢?如果您能给我一些答案,我将不胜感激:) 我的
我使用grocery-crud 进行简单的 SQL 选择 $crud->set_table('lista_ab'); $crud->set_relation('id_ab','lista_ab_ter
如何在 Grocery 店 CRUD 中使用 mysql AES 解密来匹配表中的数据? 获取 CRUD 设置关系时出错,如下所示: $crud->set_relation(AES_DECRYPT(d
我有下表 CREATE TABLE IF NOT EXISTS `maintrequests` ( `id` int(11) NOT NULL AUTO_INCREMENT, `propID`
有没有办法让 Grocery CRUD 呈现的特定列右对齐? 在我的例子中,我只想专门右对齐 Bonus Value 列。 非常感谢您的帮助。 最佳答案 在您的 Controller 中,将您想要右对
我需要执行的函数处理 DateTime。 public function dtr() { try { $crud = new grocery_CRUD(); $
我有两张 table CREATE TABLE `tbl_patient` ( id_patient INTEGER NOT NULL PRIMARY KEY AUTO_IN
我是一名优秀的程序员,十分优秀!