Jump to content

idkwhy

Members
  • Posts

    32
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

idkwhy's Achievements

Member

Member (2/5)

0

Reputation

  1. Actually my apologies, that did work! Thank you so much for the help!!
  2. Sorry, I thought it was pretty obvious what I wanted to achieve but in retrospect I realize that it's not as straight forward as I thought I am building my own custom forums and I'm trying to have the last topic posted on the board in the same query that displays the list of all the boards I don't believe that linked solution will help me
  3. Hello, I have this SQL here: SELECT F.`board_id`, F.`board`, F.`desc`, C.`cat`, T.`topic`, T.`aname`, T.`author`, T.`tname`, T.`tdate` FROM `f` F LEFT JOIN (SELECT `topic`, `tname`, `tboard`, `author`, `tdate`, U.`name` AS `aname` FROM `topics` LEFT JOIN `people` U ON U.`id` = `author` ORDER BY `tupdated` DESC LIMIT 1) T ON T.`tboard` = F.`board_id` LEFT JOIN `f_cats` C ON C.`cid` = F.`bcat` WHERE F.`plevel` <= ? AND F.`age` <= ? ORDER BY C.`cid` ASC The syntax is fine but the problem is the subquery nested in the left join. It returns only the first row. I realize the LIMIT 1 does that. I tried to make the subquery (SELECT `topic`, `tname`, `tboard`, `author`, `tdate`, U.`name` AS `aname` FROM `topics` LEFT JOIN `people` U ON U.`id` = `author` WHERE `tboard` = F.`board` ORDER BY `tupdated` DESC LIMIT 1) T but it says that the F.`board` is an unknown column on the where clause. Not sure what to try next.. is there any alternative I can do? Originally I had the last topic ID saved to the f table as a separate column but the maintainability has been a pain in the butt since I have to update it whenever a topic is created, moved, or bumped.. Anyone can help me? It would be much appreciated! Thanks in advance to all replies
  4. Thank you Laffin! I thought of cacheing it in a not-so-similar way as well (could have sworn I said that in my post, oops...) but the idea felt hacky and that's why I wanted to post here. At any rate I am glad we're on the same page with nested queries. I am really not a fan. :/ Anyway, I am going to leave this unsovled since I'm interested in hearing other thoughts still. As I said I worry a caching system is a little hacky and hair pulling to maintain (while unlikely that I'll need to, there's still a possibility) I feel like there could be more aside from what's been said. Anyone want to add on?
  5. Just wondering what some of you say would be best practices for adding subboards to custom coded forums. I'm not a fan of nested queries (looping through parent forums then looping through child forums). But I also can't join subboards with one query since there will usually be more than one child forum to a parent. What would be a better alternative? Are nested queries the only appropriate trade off? Thanks for all help in advance!
  6. Figured it out. It was this line: RewriteRule ^(.*)$ $1.php Now.. if any patient person could explain why, that'd be awesome! And much appreciated.
  7. Seems to be a popular topic here - rewriting urls to have slashes instead of ?'s and ='s... Fortunately, my rewrite is working, but php is displaying the wrong string, and I can't figure out why. My .htaccess is: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^file/(.*)$ ./file.php?str=$1 [L] Going to something like example.com/file/anythinghere/ works but php says the $_GET['str'] is anythinghere.php/anythinghere and that's not right. In a case like that, I just need "anythinghere" Is my htaccess wrong? There is nothing in my php code that is manipulating the string to do this. If I go to example.com/file.php?str=anythinghere "anythinghere" is displayed solo
  8. This is also a really good idea, thank you @kicken Just in case someone else in the future needs this help too, I'm going to leave what else I was told, that may help..
  9. Thank you so much @Psycho I didn't plan to write the final, working query selecting all columns mindlessly without declaring which belongs to what. I'm strict about avoiding the * to begin with, this was purely for example, to try and explain what I'm trying to do. I really appreciate that you mentioned that though, it's very good advice LEFT JOINs are a really good idea, but so inefficient, like you said, that I didn't consider it. Rarely in my application do I ever search for retrieving null if the query fails, but in this case, I'm hardpressed. Perhaps if I explain the reason why, you can offer further advice. In this specific area of my application, I'm checking to determine if the user has things associated with their account, in a specific order. If the order was thrown off because the person didn't have one thing associated with their account, but had the next thing, the things they have would take the place of the things they don't have. The alternative I realized could be to run the queries separately without the UNION, but I really don't want to make multiple small queries. For efficiency purposes, I'd really rather it all be combined to one query. But.. if that is my only alternative.. I wonder if it is actually more efficient to make multiple small queries instead I can explain more if I've confused you
  10. I accidentally edited out that the second query SELECT * FROM `table2` WHERE `id` = 1 should return an empty set It isn't letting me edit it back in, so I wanted to clarify that
  11. I have been asking around but nobody seems to know the answer. I'm wondering if anyone here may know. In a query with multiple unions, is there a way to manually set their result set to null if no results are found for it? To elaborate..In a typical union query you may have several queries, like SELECT * FROM `table1` WHERE `id` = '1' UNION SELECT * FROM `table2` WHERE `id` = 1 UNION SELECT * FROM `table3` WHERE `id` = 2 UNION SELECT * FROM `table4` WHERE `id` = 3 Really basic example, but you get the point Assuming each table has 3 columns called col1, col2, col3, the result set may look like... ---------------------------- | col1 | col2 | col3 | ---------------------------- | value | value | value | ---------------------------- | value | value | value | ---------------------------- | value | value | value | ---------------------------- But what if I wanted the second (empty) query to still be in the result set? Instead of it being dropped, can it appear with null? Like.. ---------------------------- | col1 | col2 | col3 | ---------------------------- | value | value | value | ---------------------------- | NULL | NULL | NULL | ---------------------------- | value | value | value | ---------------------------- | value | value | value | ---------------------------- Is this possible?
  12. Going to give this a bump. I'm still facing this problem. I'm open to suggestion on what I should use to do this task as opposed to BootboxJS. I have tried looking but didn't find anything.
  13. Hi there, I am using Bootboxjs, Bootstrap 2.3.2 and Laravel 3. I am trying to use the prompt() function and I'm having a problem. I have CSRF protection enabled on all my forms automatically so upon submission Laravel looks for a CSRF token. The issue is there isn't one being set. Is there a way to add a hidden input field on Bootbox prompt() or is this a bug? Thanks in advance to all replies / help
  14. Thank you so much! You have pushed my thinking in the right direction
  15. Hello! I'm currently designing my user management system and I want to add levels that restrict users from certain places on the site. Right now, my database is designed so that on the users table there is a BOOL column specifically for people who have restricted access and for people who don't. 0 means unrestricted access and 1 means something is restricted. If a user is restricted, a table with all the restriction information is joined. Right now, there is an "area" column. That's going to be an integer which references the area (represented by a number). I'm just wondering, is it better to hard code it or reference it from a table in the database according to Referential Integrity? Thanks in advance to all replies!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.