The main thing that annoys me about opencart code - is queries being all over the place.
The clean way to do it - is to create query class and place all queries there. Then create datasource class - and write a function for each query call.
Advantages - all queries are in once place - so when database schema is changed - all needed changes can be found at once. Also - having database access calls in one class - lets you re-use same code - and makes it easy to change it.
Now it is just a mess.
Also - the database class is missing transaction supporting code:
function transaction_begin(){
$this->connect();
mysql_query("BEGIN", $this->cn);
}
function transaction_rollback() {
mysql_query("ROLLBACK", $this->cn);
$this->disconnect();
}
function transaction_commit() {
mysql_query("COMMIT", $this->cn);
$this->disconnect();
}
function transaction_execute($sql){
return mysql_query($sql, $this->cn);
}
function get_transaction_insert_id(){
return mysql_insert_id($this->cn);
}
The one thing I would say is that I like the fact that this code is a good start. Can we as a group contribute twoards this product and make the code function better through the resources we have and know? If Interested I would like to see us continue this project to the next level.
Certainly useful and should give more structure in especially the database class and work-arounds.
Who is online
Users browsing this forum: No registered users and 3 guests