Difference between revisions of "Developers - Porting modules from osC"

From Zen Cart(tm) Wiki
Jump to: navigation, search
m
Line 2: Line 2:
 
= Overview =
 
= Overview =
  
Many contributions for osCommerce have been ported to Zen Cart. There are a few general rules for converting osCommerce code to Zen Cart code.
+
Many contributions for osCommerce have been ported to Zen Cart™. There are a few general rules for converting osCommerce code to Zen Cart™ code.
  
  
Line 102: Line 102:
 
== Registered globals ==
 
== Registered globals ==
  
Zen Cart does not use registered globals (there is no <em style="font-family:Courier;font-style:normal;font-weight:600;">zen_session_is_registered</em>, etc). Instead, Zen Cart uses the <em style="font-family:Courier;font-style:normal;font-weight:600;">$_SESSION</em> superglobal.
+
Zen Cart&trade; does not use registered globals (there is no <em style="font-family:Courier;font-style:normal;font-weight:600;">zen_session_is_registered</em>, etc). Instead, Zen Cart uses the <em style="font-family:Courier;font-style:normal;font-weight:600;">$_SESSION</em> superglobal.
  
 
References to registered globals <em style="font-family:Courier;font-style:normal;font-weight:600;">$var</em> should be replaced by <em style="font-family:Courier;font-style:normal;font-weight:600;">$_SESSION['var']</em>.
 
References to registered globals <em style="font-family:Courier;font-style:normal;font-weight:600;">$var</em> should be replaced by <em style="font-family:Courier;font-style:normal;font-weight:600;">$_SESSION['var']</em>.

Revision as of 18:40, 26 July 2006

Overview

Many contributions for osCommerce have been ported to Zen Cart™. There are a few general rules for converting osCommerce code to Zen Cart™ code.


tep_db_query and tep_db_fetch_array

Replace code like

$my_var_query = tep_db_query("query stuff");
$my_var = tep_db_fetch_array($my_var_query);

by

$my_var = $db->Execute("query stuff");


tep_db_query and tep_db_fetch_array in if

Replace code like

$my_var_query = tep_db_query("query stuff");
if ($my_var = tep_db_fetch_array($my_var_query))  {

by

$my_var = $db->Execute("query stuff");
if (!$my_var->EOF)  {


tep_db_query and tep_db_fetch_array in while

Replace code like

$my_var_query = tep_db_query("query stuff");
while ($my_var = tep_db_fetch_array($my_var_query)) {
do_stuff;
}

by

$my_var = $db->Execute("query stuff");
while (!$my_var->EOF) {
do_stuff;
$my_var->MoveNext();
}


Referencing query fields

In situations like the following:

$my_var_query = tep_db_query("query stuff");
$my_var = tep_db_fetch_array($my_var_query);
$i = $my_var['db_key'];

replace the line

$i = $my_var['db_key'];

by

$i = $my_var->fields['db_key'];


tep_db_num_rows

Replace code like

tep_db_num_rows($my_var)

by

$my_var->RecordCount()


tep_db_insert_id

Replace code like

tep_db_insert_id()

by

$db->Insert_ID()


Add global $db

Add global $db; to all functions that now reference $db as a result of these changes.


Remaining tep_ functions

Replace tep_ prefix in remaining functions with zen_.


$osCsid

Replace references to

$osCsid

by

zen_session_id()


Registered globals

Zen Cart™ does not use registered globals (there is no zen_session_is_registered, etc). Instead, Zen Cart uses the $_SESSION superglobal.

References to registered globals $var should be replaced by $_SESSION['var'].


$HTTP_x_VARS

Replace

$HTTP_x_VARS

by

$_x

For example: $HTTP_POST_VARS becomes $_POST.

Also, remove any global $HTTP_x_VARS; lines inside functions; the new versions are superglobals and do not need to be declared global.