Jump to content

Braxton

Members
  • Posts

    15
  • Joined

  • Last visited

Posts posted by Braxton

  1. I am working with MVC and I am working on writing register method for my user class. The question I have though is: when validating the register form, should the if statements for checking length of username and password take place inside of the controller or is that something that the model should handle?

  2. I have recently restructed my local web server and implemented VirtualHosts for using a subdomain. Currently the public_html is the directory for my domain and dev.domain.com lands in the dev directory, this is all working correctly. however, when I am working in my index.html in the dev directory and call for layout.css which is in static, it retreived the layout.css from the static folder in public_html/ and not the static directory in dev. How can I get around this issue? I have included the directory structure before if that helps. Sorry if my wording for explaining this is confusing.

     

    -root

    --public_html

    ---static

    ---etc

    --subdomains

    ---dev

    ----static

    ----etc

    ---fate

     

    Is the block in the vhost conf

    NameVirtualHost *:80
    <VirtualHost *:80>
        serverName domain.com
        DocumentRoot "E:\root\public_html"
    </VirtualHost>
    
    
    NameVirtualHost *:80
    <VirtualHost *:80>
    	ServerName dev.domain.com
    	ServerAlias dev.domain.com
    	DocumentRoot "E:\root\subdomains\dev"
    	<Directory "E:\root\subdomains\dev">
    		AllowOverride All
    		order allow,deny
    		Allow from all
    	</Directory>
    </VirtualHost>
    
  3. Thanks mate. That helped much.  If I have the following line. Do I then have to JOIN the status_collective table again to get the posts of the user(id 1) maybe I was doing something wrong cause I would get each status message sometimes twice and even three times.

    JOIN status_collective sc ON sc.uid = fc.receiver

  4. I even mentioned in my post that I used a left join in case a user doesn't have a status.

    Well that part i did misunderstand, reading back at it I'm still kinda confused how its worded, but that is irrelevant.  I get what you are saying now and I see how it works some what. I've been reading over the sticky about joins and I'm still kinda "lolwut?"

  5. SELECT sc.status_message, u.name

    FROM friend_collective fc

    JOIN users u ON u.id = fc.receiver

    LEFT JOIN status_collective sc ON sc.uid = fc.receiver

    WHERE fc.sender = $currentUserID AND fc.friend_flag = 'Y'

     

    Untested, but should give you an idea of what you want to do. I've used a left-join for the status in case a user didn't have a status.

     

    Okay this has got me on the right track. Perfect actually. The only thing that I don't understnad is how I can add in a second Join or Left join to also return my status posts. What I have so far.

    SELECT u.username, sc.status_message AS status, sc.time_posted AS time
    FROM friend_collective fc
    JOIN user_collective u ON u.id = fc.receiver
    LEFT JOIN status_collective sc ON sc.uid = fc.receiver
    WHERE fc.sender = 1 AND fc.friend_flag = 'Y'
    ORDER BY sc.time_posted DESC
    LIMIT 20;

    This does return results of the friends of id 1 but not id 1's own status messages. if a friend doesn't have a status posted though, returns null. Upon trying to play around with adding a second own join I got some really nasty lookin errors in my client.

     

     

  6. Logic? I have no idea when it comes to this, but I will explain as best I can and then if someone could point my into the right direction as to where I could read more about this, that would be super! I would search google or even the forums for this, but I have no idea of how I would even really word this or what keywords.

     

    I have table?(friend_collective) with the columns id|receiver|sender|friend_flag the receiver and sender columns are simply user ids where as friend_flag is purely either Y or N. now then I have a second table(status_collective) with the columns id|uid|status_message|time_posted the uid being the user id, the rest are pretty obvious.

     

    Now what I am basically trying to do is get all the status messages for the friends of a specific user. I know how I can achieve this in PHP, but for my own learning purposes and also cause I want to know if this is even possible to achieve with mysql, meaning less php.

     

    Hope this makes sense. Not even sure if I worded this correctly.

  7. I am currently writing a simple blog script for my website and I have reached the point where I am writing in the commenting feature. I want to allow the author of a comment to also provide their url much like how wordpress comments work. The thing that I'm unsure about is the url. Some users like to simply type domain.com and other http://domain.com. My question is, is there a function or method of which would be good to use here to make sure that when a user submits the info, the url won't break or anything like that. I hope this makes sense.

  8. Sometimes I read that folks include the script tag(with javascript files) between head tags and other times I read about folks placing the script tags directly before the closing body tag. Which is the more sufficient way to do this? Does it really even matter?

  9. __destruct() needs to be public so PHP can call it.

     

    __construct() can be whatever you want. If public then anybody can instantiate the object; if protected then only it and its children can instantiate it (or in the case of child objects, call it in their constructors); if private then only the object can instantiate itself.

     

    Thank you so much for your explanation. :)

  10. This is the method I generally use for wrapping paragraphs. Hope this helps.

    function wrapBody($body){
        $temp = '';
        $lines = explode("\r\n", $body);
        foreach($lines as $line){
            if(!empty($line)){
                $temp .= "<p>".$line."</p>\n";
            }
        }
        return $temp;
    }

×
×
  • 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.