目前我使用CodeIgniter进行常规查询,即:
$sql = "
SELECT *
FROM my_table
WHERE item_id > 1
";
$q = $this->db->query($sql);
Run Code Online (Sandbox Code Playgroud)
我已经开始研究ActiveRecord,它确实看起来不错,并且无论使用哪个数据库驱动程序都具有构建查询的优势 - 但是,我通常严格使用每个项目的单个数据库类型,所以这不是真正的对我有利.
我发现在我看来,常规查询(正如我在我的示例中所示)更易读,更容易维护,因此我目前正在考虑保持常规查询.
除了上面提到的原因,我应该选择哪个,以及原因是什么?
谢谢
我已经检查了所有类似的问题,但都没有使用CI 2.1.3和Wiredesignz的HMVC解决我的问题。
我的form_validation.php配置文件中具有以下规则:
array(
'field' => 'eta-renpal-1',
'label' => 'Renpal number (1)',
'rules' => 'required|callback_check_eta_group'
),
Run Code Online (Sandbox Code Playgroud)
在我的ETA控制器中,我具有此功能(当前设置为在测试时始终无效):
public function check_eta_group($reference)
{
// Internal function for use by form validation system to check if the ETA group requirements are met.
$this->form_validation->set_message('check_eta_group', 'Other values in the group ' . $reference . ' are also required.');
return false;
}
Run Code Online (Sandbox Code Playgroud)
出于某种原因,“必需”功能有效,但回调无效。我尝试了所有其他类似的建议解决方案,但无法使它们正常工作。请帮忙?
编辑:回调似乎根本没有被调用。我什至在回调中做了var_dump()来查看屏幕上是否有输出-没有...
Edit2 ::自己查看最后一条评论-使用该替代方法可以解决问题,但这并不是我想要的。所以-如果您有更好的解决方案,请分享:-)
我尝试通过 Google Indexing API 发送 POST 请求,但不断收到 HTTP 错误 403(禁止)。
我的代码如下:
require_once '../google-api-php-client-2.2.2/vendor/autoload.php';
$client = new Google_Client();
$client->setDeveloperKey('xxxxxxxxxxxxxx');
$client->setAuthConfig('xxxxxxxxxxxxx.json');
$client->addScope('https://www.googleapis.com/auth/indexing');
$httpClient = $client->authorize();
$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish?key=xxxxxxxxxx';
$content = "{
\"url\": \"https://www.example.com/whatever.html\",
\"type\": \"URL_UPDATED\"
}";
$response = $httpClient->post($endpoint, [ 'body' => $content ]);
$status_code = $response->getStatusCode();
die('I am done...: ' . $status_code);
Run Code Online (Sandbox Code Playgroud)
我的完整回复如下:
GuzzleHttp\Psr7\Response Object
(
[reasonPhrase:GuzzleHttp\Psr7\Response:private] => Forbidden
[statusCode:GuzzleHttp\Psr7\Response:private] => 403
[headers:GuzzleHttp\Psr7\Response:private] => Array
(
[Vary] => Array
(
[0] => X-Origin
[1] => Referer
[2] => Origin,Accept-Encoding
)
[Content-Type] …Run Code Online (Sandbox Code Playgroud) 今天,我已经了解到拥有胖型和瘦身控制器被认为是一种好习惯.到目前为止,我已经反过来了,所以我认为我对MVC的理解现在已被证明是错误的.
大多数文章表明胖模型/瘦模控制器方法更好,我看到的主要原因是他们声称控制器不可重复使用.这对于CodeIgniter的标准安装来说是正确的,但是当使用像Wiredesignz的HMVC插件这样的插件时,这就成了一个问题.所以,简而言之,问题是:
具体使用Code Igniter的最佳方法是什么?
我不再考虑脂肪控制器/瘦身模型没有HMVC插件作为选项,但包括它是为了完整性.
请问你的想法?HMVC插件是邪恶的吗?
有没有办法通过API构建一系列PrestaShop产品,以便我可以在外部应用程序中使用它们?
我只是想要这样的东西:
array(
0 => array(
'name' => 'Some product',
'image' => 'path/to/image.jpg',
'id' => 1,
'description' => 'Some description of the product here',
'path' => 'path/to/product'
),
...
999 => array(
...
)
);
Run Code Online (Sandbox Code Playgroud)
我知道webservice调用,array('resource' => 'products', 'display' => 'full')但我真的不知道如何从这个webservice调用返回的内容到达我需要的数组.我想要做的就是在外部网站上显示产品卷轴,每个图像链接到商店中的产品.
我使用的是Prestashop 1.5.6.2和CodeIgniter 2.1.4.产品卷轴必须显示在CI应用程序中.
编辑1
我最接近的是:$product = new Product(1, false, 1);对于产品编号1,但它不包含图像.
使用 jQuery Bootgrid 和“默认”状态映射(成功、信息、警告、错误),但是当我自定义它时,它不起作用。这个问题的解决方案在我的情况下不起作用:Jquery Bootgrid table row color based on condition
下面是我对脚本的初始化。
$(document).ready(function(){
$("#client_list").bootgrid({
css: {
icon: "zmdi icon",
iconColumns: "zmdi-view-module",
iconDown: "zmdi-sort-amount-desc",
iconRefresh: "zmdi-refresh",
iconUp: "zmdi-sort-amount-asc"
},
ajax: true,
post: function(){
return { id: "b0df282a-c9e93b7befee" };
},
url: "get_logview/client/client",
caseSensitive: false,
selection: false,
multiSelect: true,
rowSelect: true,
searchSettings: {
delay: 100,
characters: 3
},
keepSelection: true,
statusMappings: {
4: "loglow",
5: "logmediumlow",
6: "logmedium",
7: "logmediumhigh",
8: "loghigh",
9: "logcritical",
10: "logcatastrophic"
}
});
});
Run Code Online (Sandbox Code Playgroud)
我的数据确实包含正确的状态值,如下所示:
{
"current": …Run Code Online (Sandbox Code Playgroud) codeigniter ×3
php ×3
activerecord ×1
controller ×1
database ×1
jquery ×1
model ×1
validation ×1