Jump to content

sKunKbad

Members
  • Posts

    1,832
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by sKunKbad

  1. First, you have a constants config file for a reason. You shouldn't have to load a helper just to define a constant. Define your constants in config/constants.php.

     

    Secondly, CI makes it easy for you to have constants.php files that match the environment. So for development you would have a file config/development/constants.php, and for production you would have config/production/constants.php.

     

    Last, instead of wasting your energy always using your constants as you have shown above, why not just create a new or modified function in MY_html_helper.php? The HTML helper already has an img() function, so either tweak that one to use your constants, or create a new one. That way, all you do is call your function, which is a lot easier.

  2. As long as the others didn't actually steal the car, I'm sure you can get a claim from their insurance.

     

    They will find whoever owns the car.

     

    A girl growing up near me stole her parents car while drinking at age 16, during her joyride she wiped out 12 cars.

     

    Her parents had to pay for all damages and she couldn't get her license until age 21.

     

    She ran as well.

     

    Dang ... 12 cars. If that was my daughter, I don't even know what punishment would be good enough. I think I would have asked the cops to put her in juvenile detention.

  3. Yeah, I called the cops. They came, took a report, looked for the guys that ran off, and towed away their vehicle. I assume that at least the passenger was hurt, because there was blood on the seat. I don't really know though.

     

    The good news is that it looks like I will for sure get some money for the van, because I had some coverage that I wasn't aware of.

  4. Somebody hit and run my mini-van that was parked on the street last night. I can still drive it, but the car that hit it looks totaled. They got out and ran away before we were able to get a look at them. This was at about 2 in the morning. They were probably drunk or on drugs and wanted to avoid getting a DUI. Sucks.

     

    The van wasn't worth much, but I had just filled the gas tank ($80.00). I drove it today but the left front wheel rubs when I turn.

  5. Barand, I have a question about the subquery. In another instance I need a count of the rows that the subquery returns. Is this my best option:

    SELECT
      COUNT(*) AS count
    FROM
      (SELECT
        DATE(time) AS call_day,
        COUNT(*) AS totcalls
      FROM
        calls
      WHERE user_id = 256457173
        AND TIME >= CURDATE() - INTERVAL 1 YEAR
      GROUP BY call_day
      HAVING totcalls >= 100) AS whatever
    
    

    It works, but I figured you would have a better way, yes?

  6. For the benefit of all (as well as my future reference), I wanted to show the query that I ended up using:

    SELECT COUNT(DISTINCT(DATE(TIME))) AS COUNT
    FROM appointments a
        INNER JOIN
            ( SELECT 
                DATE(TIME) AS call_day
                , COUNT(*) AS totcalls
                FROM calls 
                WHERE user_id = ? 
                GROUP BY call_day
                HAVING totcalls >= 150
            ) AS tot ON tot.call_day = DATE(a.time)
    WHERE a.user_id = ?
    

    Again, this is just counting the number of days in the last year where there were more than 150 calls and at least one appointment was made.

     

    I guess what I didn't know, which made the query work, was that a selected field alias could be used as a condition, and also that the ON part of the join could use the alias as well. My logic on how to retrieve the count was flawed too. I guess I need more experience. In the past I would have just done simple queries and processed everything in PHP, but I've been trying to make MySQL do as much work as possible (aka doing things the right way), hence the stupid questions in the last few weeks/months.

     

    Thanks again Barand!

  7. I need help with a query.

     

    I've got a table that stores references to calls that come in to our office. It has a datetime field, and for the purposes of the query, it's the only thing in this table that is important.

     

    I've got another table that stores appointment information. The appointment start time is also a datetime field. For this query, this start time is the only thing in this table that is important.

     

    I need to know how many times in the last year there was a day when we had at least 150 calls come in and made at least 1 appointment.

    SELECT COUNT(*)
    FROM appointments a
    LEFT JOIN (
      SELECT DATE(time)
      FROM calls
      WHERE <there are at least 150 calls on a day>
    ) c 
    ON DATE(a.start_time) = c.time
    WHERE a.start_time >= CURDATE() - INTERVAL 1 YEAR 
    

    To make things difficult, I guess the time would have to be converted to a day, because I'm looking for all days where there was an appointment, and the datetime field is too specific.

     

    I've been looking online for 30 mins or so, and was hoping somebody here could point me in the right direction. I'm not making much progress by myself.

  8. Without any procedural coding experience, it's doubtful that you could learn PHP enough to make anything useful. Evidence pointing to this fact are the super simple questions that beginners are asking in the framework forums. The frameworks being primarily OOP, they offer lots of shortcuts, but they don't teach somebody PHP. The way that functions are used compared to methods needs to be learned. The global nature of variables compared to class properties with certain visibility needs to be learned. There are too many things to list when comparing the differences between procedural and OOP coding. You really can't just learn procedural or OOP, you need to learn both to really know your PHP. For now, just investigate all of the things you don't understand, and then over time you will realize that the learning process never stopped. I've got about 8 years PHP experience and still learning. When you're comfortable with PHP, then you'll realize you need to know more about CSS, HTML, JavaScript, Apache, MySQL, SQLite, XML, Python, Ruby, Bash, Sass, etc, etc, etc.

  9. Here is your code:

    var formatNav = function() {
    //replacing nav code sale link for mall
    $('.sf-menu li a').last().html('Visit the mall');
    $('.sf-menu li a').last().attr('href', 'http://mall.myflashtrash.com/');
    $('.sf-menu li a').last().attr('target', '_blank');
    

    This looks like jQuery code (JavaScript).

     

    Your question isn't very clear. Do you want to use JavaScript to create a simple link?

  10. Email address? I'm working on a project right now that allows a person to create their own account, but they must start by entering an email address, which then gets checked for an existing record, since email address is a unique field in the user table. If it's a parent's email address, they may have multiple kids, but doubtful that the parent will have more than one kid with the same name. I think it's safe to assume that every adult on the internet has an email address, so perhaps that can be your key. Students who sign up should be asked for their parent's email address, which would be a required field. It's just an idea...

  11. You could eliminate the free typing of school names by providing a dropdown. If there are too many schools for a dropdown, then perhaps dynamically populate the school dropdown by the value of another dropdown, such as city.

     

    Most students will have a home phone number, and while possible, it would be extremely rare that a family would have two kids with the same first name. Formatting of the telephone number ensures that it can be matched against the database, so a phone number is something you could use to identify a student.

     

    SSN numbers are obviously very unique, and searching for them in the database is not difficult, even when you have encrypted the numbers.

     

    I know people can change their phone number, but phone number combined with first name is a good indicator that you are dealing with the same student. Phone number alone can usually identify a home location.

  12. jazzman1, there sure is a lot to learn. I've started reading the LPI Linux essentials exam preparation, thinking that I would just breeze through it, but that's certainly not the case:

     

    https://shop-download.linupfront.de/cc/lxes-en-manual-cc.pdf

     

    I've only worked on Ubuntu Desktop, Ubuntu Server, and CentOS Server. Right now I'm working as a web dev and design freelancer, and I stay busy, pay the bills, etc. I wouldn't say it's boring, but I'd like to be in a position to do something else. I was thinking to self-teach myself Linux system administration, but wow is there so much to learn.

     

    Are you self taught, or study at a school?

  13. The -i (simulate initial login) option runs the shell specified by the password database entry of the target user as a login shell in that case sudo it will read the skunkbad's password. If you create another regular user account, for instance jazzman:password and grant it as root using the sudoers security policy, sudo will read his password when you're logged in to his current shell. As for the last question, running a su command, it seems that your "skunkbad" account is not permitted to use it. Su and Sudo are not the same.

     

    Thanks for your response. It's odd to me that su and sudo -i would be different, and you are correct. I think that the differences are the PATH and some environment variables, according to this:

    https://help.ubuntu.com/community/RootSudo#Special_notes_on_sudo_and_shells

     

    When I specify a new password for root, I am able to use su.

     

    Is there a difference between "sudo su" and just "su"?

  14. I've been doing a lot of studying of Linux lately. I enabled the root acount to do some work. When done, even if I logout, close the terminal, or reboot, I can still access the root account without supplying the root password. So what am I not understanding or what am I doing wrong? I don't really need to disable the root account, but this is just a learning experience, and I'm not understanding why I still have access. See below:

     

     

    # I needed to enable root access for something

    skunkbad:~$ sudo passwd root

     

    # I did what I needed to do

    skunkbad:~$ sudo -i

    root@ubuntu-Inspiron-3647:~#

     

    # I logout from root

    root@ubuntu-Inspiron-3647:~# logout

     

    # I disable the root access per instructions from many internet references

    skunkbad:~$ sudo passwd -dl root

     

    # Root access is still available, even if I close and reopen the terminal

    skunkbad:~$ sudo -i

     

    # I logout from root

    root@ubuntu-Inspiron-3647:~# logout

     

    # Trying to access root via su prompts for password, and old password is wrong

    skunkbad:~$ su

    Password:

    su: Authentication failure

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