SELECT
`materials`.`id`,
`materials`.`uid`,
`materials`.`title`,
`materials`.`type`,
`materials`.`tag`,
`materials`.`description`,
`materials`.`content`,
`materials`.`photo_list`,
`materials`.`video_list`,
`materials`.`view`,
`materials`.`likes`,
`materials`.`share`,
`materials`.`comment`,
`materials`.`customer`,
`materials`.`create_time`,
`materials`.`is_top`,
`materials`.`status`
FROM
`ap_material_like` `like_material`
INNER JOIN `ap_materials` `materials` ON `materials`.`id` = `like_material`.`material_id`
WHERE
`materials`.`seller_id` = 2
AND `materials`.`status` = 1
AND `materials`.`display` = 1
AND
(
`materials`.`m_category_id` IN ( 10001, 10005, 10008 )
AND ( ( `materials`.`tag` LIKE '%胖%' ) OR ( `materials`.`content` LIKE '%胖%' ) )
AND `like_material`.`uid` = '196893'
AND `like_material`.`typeid` = 3
AND `like_material`.`status` = 1
)
OR (
`materials`.`m_category_id` IN ( 10011, 10012, 10013, 10014, 10015 )
AND ( ( `materials`.`title` LIKE '%胖%' ) OR ( `materials`.`description` LIKE '%胖%' ) OR ( `materials`.`tag` LIKE '%胖%' ) )
AND `like_material`.`uid` = '196893'
AND `like_material`.`typeid` = 3
AND `like_material`.`status` = 1
)
ORDER BY
`like_material`.`create_time` DESC
LIMIT 0, 20
Alors ce dont j'ai réellement besoin, c'est
SELECT
`materials`.`id`,
`materials`.`uid`,
`materials`.`title`,
`materials`.`type`,
`materials`.`tag`,
`materials`.`description`,
`materials`.`content`,
`materials`.`photo_list`,
`materials`.`video_list`,
`materials`.`view`,
`materials`.`likes`,
`materials`.`share`,
`materials`.`comment`,
`materials`.`customer`,
`materials`.`create_time`,
`materials`.`is_top`,
`materials`.`status`
FROM
`ap_material_like` `like_material`
INNER JOIN `ap_materials` `materials` ON `materials`.`id` = `like_material`.`material_id`
WHERE
`materials`.`seller_id` = 2
AND `materials`.`status` = 1
AND `materials`.`display` = 1
AND ( {括号开头}
(
`materials`.`m_category_id` IN ( 10001, 10016, 10017 )
AND ( ( `materials`.`tag` LIKE '%胖%' ) OR ( `materials`.`content` LIKE '%胖%' ) )
AND `like_material`.`uid` = '196893'
AND `like_material`.`typeid` = 3
AND `like_material`.`status` = 1
)
OR (
`materials`.`m_category_id` IN ( 10020, 10021, 10022, 10023, 10024 )
AND ( ( `materials`.`title` LIKE '%胖%' ) OR ( `materials`.`description` LIKE '%胖%' ) OR ( `materials`.`tag` LIKE '%胖%' ) )
AND `like_material`.`uid` = '196893'
AND `like_material`.`typeid` = 3
AND `like_material`.`status` = 1
)
){括号结束}
ORDER BY
`like_material`.`create_time` DESC
LIMIT 0, 20
répondreMerci monsieur, mais utiliser la version native de mon code est un peu compliqué et pas très simple à utiliser. Je viens d'écrire ici un exemple simple. J'ai utilisé une requête de fermeture dans mon projet.
Le code dans le projet
La déclaration SQL imprimée est
Alors ce dont j'ai réellement besoin, c'est
Et le mot-clé est toujours comme ça
$sql = '你的sql';
$result = Db::query($sql);