您的SQL语法有错误; 检查与您的MySQL服务器版本对应的手册,以便在'WHERE j附近使用正确的语法.id_customer第4行= 1'
SELECT j.`id_customer`, j.`id_order`, m.`id_shop`
FROM `ps_orders` j
LEFT JOIN `ps_order_detail` m
WHERE j.`id_customer` = 1
Run Code Online (Sandbox Code Playgroud)
这是从prestashop php中的原始代码生成的,如果打开详细的错误纠正-------
foreach ($result as $key)
{
$customer_id_is = 1;
$product_id_is = 5;
$result2 = Db::getInstance()->executeS(
'SELECT j.`id_customer`, j.`id_order`, m.`id_shop`
FROM `'._DB_PREFIX_.'orders` j
LEFT JOIN `'._DB_PREFIX_.'order_detail` m
WHERE j.`id_customer` = '.$customer_id_is.'
');
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试并且未能将我相对简单的SQL语句转换为可在Doctrine中工作的语句.
这是SQL语句,在针对我的数据库运行时根据需要运行:
SELECT a.*
FROM score a
INNER JOIN (
SELECT name, MAX(score) AS highest
FROM score
GROUP BY name
) b
ON a.score = b.highest AND a.name = b.name
GROUP BY name
ORDER BY b.highest DESC, a.dateCreated DESC
Run Code Online (Sandbox Code Playgroud)
这是迄今为止的DQL尝试:
$kb = $em->createQuery(
"SELECT a
FROM ShmupBundle:Score a
INNER JOIN a.name ShmupBundle:Score b WITH a.score = b.score AND a.name = b.name GROUP BY b.name
WHERE a.platform='keyboard'
GROUP BY a.name
ORDER BY b.score DESC, a.dateCreated DESC"
);
Run Code Online (Sandbox Code Playgroud)
目前正在提供此错误:
[Semantical Error] line …Run Code Online (Sandbox Code Playgroud) 我想在树枝页面中使用单个语句来初始化多个变量。我该怎么办?下面是我的代码,它看起来很可怕。
{% set t1Tot = 0 %}
{% set t2Tot = 0 %}
{% set t3Tot = 0 %}
{% set c1Tot = 0 %}
{% set c2Tot = 0 %}
{% set c3Tot = 0 %}
{% set o1Tot = 0 %}
{% set o2Tot = 0 %}
{% set o3Tot = 0 %}
{% set grandTot = 0 %}
Run Code Online (Sandbox Code Playgroud) 我有两个表tbl_user和tbl_favItems如下所示:
+-----+----------+ +-----+----------+
| ID | Name | | ID | Name |
+-----+----------+ +-----+----------+
| 1 | Johan | | 1 | Movies |
| 2 | Peter | | 2 | Food |
| 3 | Kevin | | 3 | Mobiles |
| 4 | Harry | | 4 | Sports |
+-----+----------+ +-----+----------+
User Table Fav. Table
Run Code Online (Sandbox Code Playgroud)
在这里我需要一些逻辑:假设Johan可以有收藏.Movies, Mobiles,并且Peter可以有青睐.Food, Mobiles, Sports.等等;.在这种情况下,我怎么可以涉及fav.ID 1,3到Johan,并fav.ID 2,3,4 …
我试图在循环中检查我的帖子是否有内容.目前,我在循环中添加了一个条件:
if ( $post->post_content )
Run Code Online (Sandbox Code Playgroud)
和推论的论点
wp query ('posts_per_page' => 8).
Run Code Online (Sandbox Code Playgroud)
我认为它有效,但实际上,WP query去找最后8 posts,检查那些内容8 lasts.所以它呈现2或3发布.
我想要的是一种显示8有内容的帖子的方法.
明白了吗 ?
我真的很感激一些帮助:)
最好的祝福.
我正在使用任务管理器,其中有两种类型的用户:管理员(所有权限)和用户(有限权限).
这是控制器中的任务功能
function task($id) {
$data = array(
'query' => $this->main_model->get_task($id),
'task_id' => $id,
);
$data2['comments'] = $this->main_model->get_comments($id);
$this->load->library('form_validation');
$this->load->helper('security');
$this->form_validation->set_rules('comment_text', 'comment_text', 'trim|required|strip_tags|xss_clean');
if ($this->form_validation->run() === FALSE)
{
if($this->main_model->get_task($id))
{
foreach ($this->main_model->get_task($id) as $tas)
{
$data = array(
'title' => $tas->task_name,
'desc' => $tas->task_description,
'date_created' => $tas->date,
'date_started' => $tas->task_start_date,
'deadline' => $tas->task_deadline,
'creator' => $tas->task_creator,
'owner' => $tas->task_owner,
'attach'=>$tas->attachment_name,
'status'=>$tas->task_status,
'priority'=>$tas->task_priority,
'task_id'=>$tas->ID_task,
'base_url' => base_url()
);
}
$data1 = array(
'emps' => $this->main_model->get_employees(),
'creator' => $this->main_model->get_details($id),
'owner' => $this->main_model->get_owner($id) …Run Code Online (Sandbox Code Playgroud) mysite.com 我希望能够允许这个二十世纪儿童主题的用户能够将特色图像上传到页面(而不是帖子)并使其动态地成为背景图像(基本上按照现在的方式定位 -请参阅thesite.com)我认为它需要一个动态网址(如wp_get_attachment_thumb_url),虽然我没有使用循环.(我以为必须在循环中使用函数.
我使用下面的代码作为模板部分.这就是在首页上生成内容的原因.所以基本上,我需要获得这个特色图像,并将其用作背景部分的背景图像,而不是在循环内部.
<?php $page = get_page_by_title ( 'Welcome' ); ?>
<div id="welcome-intro" class="clear">
<?php if ( get_the_post_thumbnail ( $page->ID ) ) : ?>
<figure class="entry-page-image">
<?php echo get_the_post_thumbnail ( $page->ID, 'full'); ?>
</figure>
<?php endif; ?>
<article id="intro-elements">
<div class="welcome-entry-content">
<?php echo apply_filters( 'the_content', $page->post_content); ?>
</div>
</article>
</div>
Run Code Online (Sandbox Code Playgroud)
/*>>>>>>>>>>>>>>修改了<<<<<<<<<<<<<<<*/
<?php
// welcome message ?>
<?php $page = get_page_by_title ( 'Welcome' ); ?>
<?php if ( $background = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'full' ) ) : ?>
<div …Run Code Online (Sandbox Code Playgroud) 我试图用$this->post()json格式发送邮件发送的数据.我无法得到任何结果$this->post('name').
这是代码:
<?php
require(APPPATH . '/libraries/REST_Controller.php');
class user_api extends REST_Controller {
function user_post() {
$user = array(
'id' => null,
'firstname' => $this->post('firstname'),
'lastname' => $this->post('lastname')
);
$result = $this->user_model->insert($user);
if ($result) {
$this->response($result, 200); // 200 being the HTTP response code
} else {
$this->response(NULL, 404);
}
}
}
?>
Run Code Online (Sandbox Code Playgroud)
以json格式发送到链接的数据:http://mydomain.com/myapplication/user_api/user:
{"firstname":"test",
"lastname":"test"
}
Run Code Online (Sandbox Code Playgroud)
数据库中没有数据,因为它无法从中获取数据$this->post('firstname').
任何的想法 ????
我试图找出wordpress如何处理每个请求并返回结果.我发现wp()函数调用$wp->main()反过来调用$this->query_posts();,哪些调用$wp_the_query->query($this->query_vars)函数在query.php文件中.该query()函数调用 return $this->get_posts();并返回结果.
我的问题是没有看到任何变量接收到这个返回值,所以为什么这个函数已经返回,即使wordpress工作,如果我从代码中删除返回.那么这个回报的目的是什么,(我猜这个代码将内容(帖子)保存到$this->posts变量).顺便说一下我用的是wp 3.6
使用具有结构的表:
id | count
/string/id1 | 3
/string/id1/r1 | 2
/string/id1/r2 | 1
/string/id2/r1 | 2
/string/id2 | 3
/string/id2/r1 | 2
/string/id3/r1 | 5
Run Code Online (Sandbox Code Playgroud)
我想选择id中需要子字符串的所有行。
即我需要 id 中有子字符串的所有行: /string/id1和/string/id2
查询应该很简单 - 简单的 sql:
select * from table_name where id LIKE '/string/id1%' OR id LIKE '/string/id2%';
Run Code Online (Sandbox Code Playgroud)
结果应该是:
id | count
/string/id1 | 3
/string/id1/r1 | 2
/string/id1/r2 | 1
/string/id2/r1 | 2
/string/id2 | 3
/string/id2/r1 | 2
Run Code Online (Sandbox Code Playgroud)
不幸的是,如果您尝试在 symfony 和doctrine2 中使用相同的查询:
$ids = array('/string/id1', '/string/id2');
$query …Run Code Online (Sandbox Code Playgroud)