Reputation: 120 Stalwart
- Active Members
- Active Posts:
- 1,275 (0.77 per day)
- 01-June 09
- Profile Views:
- Last Active:
- Aug 20 2012 11:17 AM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Who Cares
- Dream Kudos:
Posts I've Made
Posted 10 Jul 2012I'm not sure I understand your question or your concern. Could you please elaborate? Thank you.
Posted 11 Jun 2012In all honesty, it really is to make it "pretty" for the human users. Maybe not even so much the human users, but myself. I just like nice looking urls.
Posted 11 Jun 2012After rereading this and thinking more about what I'm asking, I realize what I'm requesting my actually be imposisble.
But what about this: Can you keep like a counter in mod_rewrite
So I could always convert something like this:
Posted 11 Jun 2012That query will, as you said, query the person table and retrieve the first_name and last_name fields. Everything after WHERE in an SQL statement is considered the WHERE Clause. In this specific WHERE Clause, you're using the id field to narrow down your search in the db table.
In this example, $inAuthorId was probably already set to something, most likely a number, but doesn't have to be. Now in the mysql_query function, you're concatenating the first part of the query and this variable. So if the variable's value was 2 your query would look like:
SELECT first_name, last_name FROM people WHERE id = 2
So this query will return the first_name and last_name of the row in the people table which has id equal to 2.
If I were doing this in PDO it'd look something like:
$sql = "SELECT first_name, last_name FROM people WHERE id = :theId"; $result = self::$pdo->prepare($sql); $params = array( 'theId' => $inAuthorId ); $result->execute($params); $result->bindColumn('first_name', $firstName); $result->bindColumn('last_name', $lastName); $result->fetch(\PDO::FETCH_BOUND);
For more info on PDO: http://php.net/manual/en/book.pdo.php
Posted 10 Jun 2012But, in terms of having a class that represents a DB table, I personally don't see this as a good pattern. Basic functions for table interaction can be made generic, and so are not reliant on the table itself. Interaction with a DB necessitates unique classes when the relational model itself becomes unique. Let's say, for example, you have a DB schema where there is a table Employees, a table Positions, and a table Departments. If you want to get the following information:
Oh, and about this: Well, what I meant was my Domain Objects have properties for like DB fields. Like a Member Domain Object would have dateStarted, displayName, address, etc. But they are not just glorified data holders. They have methods that may even use other Domain Objects to get data.
- Member Title:
- Garbage Collector
- 23 years old
- February 14, 1990
- New York
- TRACK, computer science, video games
- Years Programming:
- Programming Languages:
- Learning: Java, C#, PHP, MySQL, HTML/CSS, Flex