I'm working on a little page system and I was just wondering the best way of getting the info.
I have the regular stuff in my table, id, page_name, page_body but I also have two other fields, isHome and isBlog, so if either of those are true (they're bool) I only wanna get the info from those pages.
And just to minimize my query usage I use the same query to get the page_name for navigation links.
I was thinking I could pass a variable in the URL and then set up an if statement to check if the variable is set and if it is it will execute a query to get the specific info.
But I will end up with two queries then, is there someway I could do this in just one?
'Cause right now I need one query to get the navigation info and if I then wanna get the content of the specific page I need another one. It's not a terrible slow down, just asking if there is a more efficient way...
Efficient way of getting info
Re: Efficient way of getting info
Not really sure what you meanEcazS wrote:so if either of those are true (they're bool) I only wanna get the info from those pages.
you could use a JOIN or UNION if its appropriate. What is the content you are getting for the navigation, a list of pages ? Or full HTML ?EcazS wrote:But I will end up with two queries then, is there someway I could do this in just one?
Re: Efficient way of getting info
I don't think a join would be good for this.
Right now I have it set up like this,
id name order body isHome isBlog
and then I'm getting the Name and echoing it like a navigation list. I currently have two rows,
1 Home 0 Homepage 1 0
2 Blog 10 0 1
And this is the query I'm using,
Two queries on a page isn't that much and it's not going to slow down very much. But still, wanna try and get it in one, is possible.
Right now I have it set up like this,
id name order body isHome isBlog
and then I'm getting the Name and echoing it like a navigation list. I currently have two rows,
1 Home 0 Homepage 1 0
2 Blog 10 0 1
And this is the query I'm using,
SELECT `name`, `content`, `isBlog`, `isHome` FROM `pageinfo` ORDER BY `order` ASCBut if I wanted to get the content of the active link (index.php?page=home) I would have to use WHERE in the query with the GET variable. So that would be two queries, right? But I also wanna check if the active link is the blog (isBlog = 1).
Two queries on a page isn't that much and it's not going to slow down very much. But still, wanna try and get it in one, is possible.
Re: Efficient way of getting info
So you want the `name` for all pages and the `content` for the one being viewed ? That will have to be two queries I think. It's good that you are trying to use as few as possible, but as you say 2 is not loadsEcazS wrote:But if I wanted to get the content of the active link (index.php?page=home) I would have to use WHERE in the query with the GET variable. So that would be two queries, right? But I also wanna check if the active link is the blog (isBlog = 1).
Re: Efficient way of getting info
Alright, I'll go for two then