Jump to content
Sign in to follow this  
devosc

MS2/3 database, session, cache, messagestack

Recommended Posts

Would it be of interest to anyone if a set of MS3 (type) class files and their corresponding MS2 functions be made as a contribution ?

 

For example, I currently have a development catalog, which now has the following MS3 type class files, these files are intended to be forwarded compatible (with some minor changes) but also having functions (methods) that can the be called by the current MS2-2.2 functions, for tep_db_perform.

 

osC_Database,

osC_Session,

osC_Cache

osC_MessageStack

 

As said these classes are my intepretations, and hopefully will provide forward compatibility, the only dubious one is osC_Session if they decide to remove the methods [exists, set, value] hopefully they won't because I believe it better to still protect $_SESSION in case code is written setting this autoglobal prior to the session actually starting (the data will be lost)...

 

osC_MessageStack is not a drop in, but it is self contained and is used db class - wouldn't be hard to replace with existing messageStack (as it is now a static class).

 

Small caveat, MS3 db class does not die on error so this would have to figured out (or forced for MS2-2.2 installations)...

 

So for example as a replacement for the MS2-2.2 tep_db_perform function the corresponding function is now:

 ?function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {
? ?if ($action == 'insert') {
? ? ?$GLOBALS['osC_Database']->insert($table, $data);
? ?} elseif ($action == 'update') {
? ? ?$GLOBALS['osC_Database']->update($table, $data, $parameters);
? ?}
?}

 

And the corresponding MS3 (type) database class is (in the case of an 'insert')

 ? ?function insert($table, $data)
? ?{
? ? ?if (!is_array($data) || empty($data)) {
? ? ? ?return FALSE;
? ? ?}
? ? ?$_Result = & new osC_Database_Result($this);
? ? ?$_Result->setQuery('INSERT INTO '.$table.' ('.implode(', ',array_keys($data)).') VALUES ('.implode(', ',array_values(array_map(array(&$_Result,'buildEscapedString'),$data))).');');
? ? ?$_Result->execute();
? ? ?return $this->nextID();
? ?}

 

So with the newly revised tep_ functions, these files can be dropped into and MS2-2.2 catalog and seemlessly immediately integrated, while giving any future code the ability to use the new MS3 style methods...

 

One benefit is the less cumbersome cohersion between database queries and caching the results....

 

Obviously this is would be for seasoned users.

 

Thought to propose this question before uploading etc ? Give a shout if of any interest --- although please note, I have only quickly tested things out, so if any existing code is not MS2-2.2 standards compliant - and in _any-event_ I won't be responsible :blush:

 

*Edit* - The files may be found here

Edited by Johnson

"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

it is brave to attempt forward compatibility, though I personally think backward compatibility will be easier to implement (with its limitations) and more popular while the MS2 contribution base is being migrated/rewritten for MS3.


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites

Have you tried dropping these contrib classes into an MS2-2.2 catalog ? It should work with only one change in specifying in the DIR_FS_WORK dir... in the osC_Cache dir (which needs to have write permissions -- the default is 'oscommerce_data')...

 

Not sure I understand, forward compatibility --- to me, in this instance, this means having the finalized version (or staying current etc..) and making it backwards compatible ? The contribution classes provide backward compatibility (to the largest, or most common, degree), however intepretations have been made for forward compatibility, primarily to make where possible classes available via static calls, e.g. osC_MessageStack::add() rather than $osC_MessageStack.. subtle changes such as this would not be difficult for those familiar with osCommerce and some understanding of PHP... But maintenance of these classes to accomodate future or later revisions for compatibility would be required if neccessary.. So this features are available only if they wish to be used, in terms of MS2-2.2 they are transparent.

 

Some changes & additions, for personal accomodation has been made, such as setResults, there are times when a query is made and its results merged with another set of results, and batch links similiar to here in the forums, but these are additional changes which cause no noticeable affects etc...


"Any fool can know. The point is to understand." -- Albert Einstein

Share this post


Link to post
Share on other sites

What can I say ... correct . full stop.

 

(guess it shows I'm not native english, so my discourses are typically a bit shorter :) )


KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Share this post


Link to post
Share on other sites

Hello devosc,

 

thanks for this great contribution. Our website is loaded faster and faster :thumbsup:

 

But, maybe we did found a bug in you database core file. We have in german zip codes which begins with the number 0, e.g. 04299 Leipzig.

Since the install of your core files the database field "customers_postcode" in table "orders" will filled without the number 0, so the zip code changes from 04299 to 4299. :o

 

Maybe the string will be interpreted as integer. Can you explain, how we can solve this problem?

 

Thanks.

Edited by poponaut

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×