Zeka Posted March 20, 2022 Share Posted March 20, 2022 Hi. Is there a way to find pages by $page->meta data? Thanks. Link to comment Share on other sites More sharing options...
bernhard Posted March 20, 2022 Share Posted March 20, 2022 Only option I know is plain SQL: <?php // populate test value $pages->get(1)->meta('foo', 'foo'); // find pages $result = $database->query("SELECT source_id FROM pages_meta WHERE name = 'foo' and data = '\"foo\"'"); $ids = implode("|", $result->fetchAll(\PDO::FETCH_COLUMN, 0)); db($pages->find("id=$ids")); If you use this with user input be sure to properly sanitize the data and maybe use prepared statements! 2 Link to comment Share on other sites More sharing options...
adrian Posted March 20, 2022 Share Posted March 20, 2022 A couple of potential things - I think getByIDs would be more performant. And also, if you have JSON in the meta, then using JSON_VALUE might be helpful. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now