Jump to content

Highlander

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Highlander's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I don't see any problem with just having one database and multiple tables, and then give different applications different type of access to the data (using views or stored procedures). There is no need for using multiple databases when you have connections to different tables.
  2. It's becuase the variabels used in the form are not set yet. How do i work around this? <?php $first = isset($_POST['first']) ? $_POST['first'] : ""; ... First: <input name="first" type="text" value="{$first}" /> {$errors['first']} <br /> ?>
  3. I always use setName() and getName() since I believe that the __get and __set methods removes the clarity of what types of properties an object have. I know that __get and __set can create a more dynamic structure, but that is the price I pay for a clearer code.
  4. I would recommend the second one in your example since the first one adds a dependency that the Util class needs to know about the database when you write test-cases
  5. One site that I find minimalistic but with much information, is http://zenhabits.net. Maybe get some ideas from there
  6. class b extends a{ function show_name($name = null){ if ($name != null) echo $name; } else { echo $this->name; } } } That should work
  7. You would never update a primary key. It is used in the WHERE claus of the update query to define what record to update UPDATE users SET name='joe', email='joe@123.com' WHERE userId='123' I suggest you spend some time on database normalisation Yea, this is the case for normal database with no temporal support. In temporal database you need an ID for each update to the object in a unique row. After some thinking and help from a friend, here is the solution for the database schema: -- Author: Johan Grahn -- Database schema for my blog DROP DATABASE IF EXISTs high_blog; CREATE DATABASE high_blog CHARACTER SET = utf8; USE high_blog; CREATE TABLE user ( username varchar(40) NOT NULL, password varchar(40) NOT NULL, first_name varchar(40) NOT NULL, last_name varchar(50) NOT NULL, id int NOT NULL, revision int NOT NULL DEFAULT 1, st timestamp NOT NULL DEFAULT now(), et timestamp NULL DEFAULT NULL, PRIMARY KEY(id, revision) ) ENGINE=innodb CHARSET=utf8; CREATE TABLE blog_entry ( id int NOT NULL, revision int NOT NULL DEFAULT 1, title varchar(100) NOT NULL, content text NOT NULL, st timestamp NOT NULL DEFAULT now(), et timestamp NULL, author int NOT NULL, author_revision int NOT NULL, PRIMARY KEY (id, revision), FOREIGN KEY (author, author_revision) REFERENCES user(id, revision) ) ENGINE=innodb CHARSET=utf8; In this schema, I store each update to the id in a unique revision so that each user with a given ID can have multiple revisions (each revision contains the updated data for the user).
  8. But this will not work, since the ID will change every time a change is made to the user row (id column has auto_increment), since a new row is inserted for every change so that you can track each change. Hm, I think I need to read more about this.
  9. Hello! I'm trying to build a blog and use a database design that can record history using temporal data. I have a user table that looks like this: CREATE TABLE user ( id int NOT NULL AUTO_INCREMENT, username varchar(40) NOT NULL, password varchar(32) NOT NULL, first_name varchar(40) NOT NULL, last_name varchar(50) NOT NULL, -- Temporal columns st timestamp NOT NULL DEFAULT now(), et timestamp NULL DEFAULT NULL, PRIMARY KEY(id) ) ENGINE=innodb CHARSET=utf8; Now I want to have a blog_post table with a author id connected to the user table, but how do I uniquely store a identifier to the user? My first though was to store ID + st in blog_post table, but it doesn't seem right. Any hints on this?
  10. I would recommend writing a shell-script that polls your directory (or even use inotify) and runs mysql queries if any new files are added. God luck!
  11. And replace #include <iostream.h> with #include <iostream> The first one is meant for C-compiler, not C++
  12. Yea, you need one connection to each database. No, MySQL will not know in which database the given table is, you will have to tell him, by using the appropriate connection.
  13. I think that with todays hardware, you will run out of bandwidth (e.g. many users) before running out of disk space, unless you do a TERRIBLE database design.
  14. Sounds like a very strange article, can you post a link to it ? A class should have ONE purpose, and ONE purpose only. Better to have 10 small classes than 1 big. Better maintainability and structure.
×
×
  • 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.