Jump to content

YAOMK

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

YAOMK's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Like steviewdr, I would suggest you start on a project, it is the best way to learn your way around the intrincities of an os and its services. If you decide to go with Linux I'd suggest you join a community such as linuxquestions.org they are very helpful and posses a wealth of information in comparison to any given book. God luck. Oh and by the way if you want to ditch that book you are reading on CSS, try "Spring Into HTML and CSS", it is very readable and straight to the point.
  2. [quote]There is a slim possibility that this code will produce a duplicate number if more than one new account is processed at the same time (before the database is updated with the new number). [/quote] This can be solved using inodb tables along with transactions.
  3. You have 2 options here, you can either serialize data into and from xml or you could use a remoting gateway such as amphp, sabre or web-orbs. Please consider reading: http://www.sephiroth.it/tutorials.php or doing a siple google search. Good luck.
  4. Cool, now I can go on write my classes. Many thanks Fenway.
  5. Hi Fenway, Thanks for your reply. I'm with you. I'm just concerned about best practices. I wanted to know if this is an efficient way doing it. Also how should I deal with my tables? a class with methods for each one? or logical classes that run queries across multiple tables? I'm very new to php and mysql, so I'm not confident on my php programming. I guess my question is; how would you do it?
  6. Hi, I'm new to php and mySQL, I'm currently developing a web application using php and mySQL as the back-end and flash as the user interface (both integrating through amfphp). I'm wondering what is the best practice to manipulate the tables in my database. Should I make a class for each table (as some articles I've read suggest) or do I make classes that contain the methods and queries necessary to carryout a particular transaction across multiple tables? Also is it a good practice to use a base class as a configuration file? I've searched for the subject without much success.Thanks in advance for your time. YAOMK Here is an example of my app thus far: <?php class Config //configuration class { protected $DB_SERVER; protected $DB_NAME; protected $DB_USER; protected $DB_USER_PASSWORD; protected $DB_AGENT; protected $DB_AGENT_PASSWORD; protected $DB_ADMIN; protected $DB_ADMIN_PASSWORD; function __construct() //set corresponding values within the quotes { $this->DB_SERVER = ""; $this->DB_NAME = ""; $this->DB_USER = ""; $this->DB_USER_PASSWORD = ""; $this->DB_AGENT = ""; $this->DB_AGENT_PASSWORD = ""; $this->DB_ADMIN = ""; $this->DB_ADMIN_PASSWORD = ""; //sets error reporting level: E_ALL, E_STRICT, E_WARNING, etc... error_reporting(E_ALL); } } ?> <?php require_once('Config.php'); require_once('c:\wamp\php\pear\DB.php'); class Database extends Config //manages all database connection using pear db. //recieves a query argument and sets either the user, admin or agent as the db user. //this class requires the pear db module and the Config class. { private $user; private $agent; private $admin; private $db; private $query; private $result; public function connect($query, $user, $agent, $admin) { $this->query = $query; $this->user = $user; $this->agent = $agent; $this->admin = $admin; if (isset($this->user) && $this->user == Config::$this->DB_USER) { $this->db = DB::connect('mysql://'.Config::$this->DB_USER.':'.Config::$this->DB_USER_PASSWORD.'@'.Config::$this->DB_SERVER.'/'.Config::$this->DB_NAME); $this->result = $this->db->query($this->query); return $this->result; exit; } elseif (isset($this->agent) && $this->agent == Config::$this->DB_AGENT) { $this->db = DB::connect('mysql://'.Config::$this->DB_USER.':'.Config::$this->DB_USER_PASSWORD.'@'.Config::$this->DB_SERVER.'/'.Config::$this->DB_NAME); $this->result = $this->db->query($this->query); return $this->result; exit; } elseif (isset($this->admin) && $this->admin == Config::$this->DB_ADMIN) { $this->db = DB::connect('mysql://'.Config::$this->DB_ADMIN.':'.Config::$this->DB_ADMIN_PASSWORD.'@'.Config::$this->DB_SERVER.'/'.Config::$this->DB_NAME); $this->result = $this->db->query($this->query); return $this->result; exit; } } } //undecided as to managing db errors in this class or the calling class. /*if(DB::isError($this->result)) { die($db->getMessage()); }*/ ?>
×
×
  • 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.