-
Notifications
You must be signed in to change notification settings - Fork 23
Migrate to p4a3
This little guide will help you migrating your 'P4A 2 applications to P4A 3', because a lot of things were changed between the old and the new version and this is a highlight.
Issues in alphabetical order:
In P4A 2 objects constructor method had the same name of the class itself (that was the PHP4 way), in P4A 3 all constructors are named __construct (this is the PHP5 way) so:
// p4a2 calling p4a constructor
parent::p4a();
// now must be converted to
parent::__construct();
The currency data type has been dropped from P4A 3, that happened because if you've international applications you won't have your data formatted with the currency symbol depending on the locale of the application, if you've a price_in_dollars field you surely do not want german users to see 1000 formatted as 1.000,00 €.
In P4A 2 you had to download the P4A_Base_Mask from the contribs repository and put it inside your application directory. In P4A 3 P4A_Base_Mask has been added to the core to you'll have to delete your local (and old) copy of p4a_base_mask.php.
This method was renamed to P4A_Mask::setRequiredField().
This method was removed in P4A 3, replace your setTitle() calls with setLabel().
You cannot use the table.column syntax anymore, the P4A_Db_Source::setFields() now only accepts columns from the main table and not from the joined ones, thus the syntax become:
$db_source->setFields(
array(
"column1" => "alias1",
"column2" => "alias2"
)
);
The old P4A_Db_Source::addJoin() syntax is changed (eg: having schema.table in the table param won't work anymore), the new syntax is P4A_Db_Source::addJoin($table, $clausole, $fields = '*', $schema = null).
A sample code is:
$db_source->addJoin(
"table2", // the joined table
"table2.column1 = table2.column2", // matching clausole
array(
"column1" => "alias1",
"column2" => "alias2"
),
"schema1" // if you have a schema
);
Never use the P4A_Db_Source::addOrder("table.column") or P4A_Db_Source::addOrder("alias") syntax anymore, you have to use P4A_Db_Source::addOrder("data_field_name").
This type of field is not supported in P4A 3 because the "file" and "image" type were joined together within the "file" type.
This method was removed in P4A 3, replace your setTitle() calls with setLabel().
In P4A 2 you could write:
$this->menu->addItem("products", "P&roducts");
using the & symbol to identify the accesskey. This feature was removed in P4A 3 thus you'll have to use
$this->menu->addItem("products")
->setAccessKey("r");
If you want to try the new P4A products_catalogue sample application while you have installed it with an old release, please be sure to 'drop the old database and recreate it from the new SQL dump' file bundled with the P4A package. This operation is due because the application changed a lot, adding more samples of P4A usage.
General:
Documentation:
Theme customizations:
Contribs: