I am moving a website into a yii2 framework. The website always calls the index page but provides content from a $_POST (?page=index&id=1) or maybe (?page=HCA&id=77). If there’s no post, or the page does not match the id, then you get the index page.
This is my existing pages table, it will be altered for yii2 slightly (ENGINE etc.)… This table holds the text for each page of the site, it’s administered by a Content Management System and the table benefits from a Nested Set Model that generates all the lft and rgt nodes for the site menu.
CREATE TABLE `pages` (
`id` int(6) UNSIGNED NOT NULL,
`page_link` varchar(32) NOT NULL COMMENT 'A unique link to reach this Page',
`parent_link` varchar(32) NOT NULL COMMENT 'What parent link reaches this Page?',
`page_rank` tinyint(3) UNSIGNED NOT NULL COMMENT 'Where is this page in the menu?',
`page_title` varchar(64) NOT NULL COMMENT 'Provide a human readable Page title',
`page_secure` char(1) NOT NULL COMMENT 'Is the Page secured?',
`pub` char(1) NOT NULL COMMENT 'Does the page appear in a menu?',
`editor` mediumtext NOT NULL COMMENT 'Page content goes here',
`page_hits` int(10) UNSIGNED NOT NULL,
`insert_at` timestamp NOT NULL DEFAULT current_timestamp(),
`insert_by` smallint(6) UNSIGNED NOT NULL,
`update_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`update_by` smallint(6) UNSIGNED DEFAULT NULL,
`lft` int(11) UNSIGNED NOT NULL,
`rgt` int(11) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
This is my existing query which works well in phpmyadmin to extract the items for the menu in the correct order.
SELECT
node.id, node.page_title, node.page_link, node.parent_link
FROM
pages AS node, pages AS parent
WHERE
node.lft BETWEEN parent.lft AND parent.rgt
AND
parent.page_link = 'index'
ORDER BY
node.lft;
After reading extensively I just cannot get my yii2 query to appear in the yii2 DB debug window to match my original query, hence it fails to work. Can any of you yii guru’s please help me by translating the original query into a yii2 query?
source https://stackoverflow.com/questions/70337560/can-you-translate-this-query-into-yii2
No comments:
Post a Comment