本文整理汇总了PHP中Zone::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Zone::add方法的具体用法?PHP Zone::add怎么用?PHP Zone::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zone
的用法示例。
在下文中一共展示了Zone::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add($nom)
{
$this->nom = $nom;
$this->unite = 0;
$this->id = parent::add();
redirige("zone.php?id=" . $this->id . "&action=showZone#zone");
}
示例2: _installStates
/**
* @param SimpleXMLElement $xml
* @return bool
* @throws PrestaShopException
*/
protected function _installStates($xml)
{
if (isset($xml->states->state)) {
foreach ($xml->states->state as $data) {
/** @var SimpleXMLElement $data */
$attributes = $data->attributes();
$id_country = $attributes['country'] ? (int) Country::getByIso(strval($attributes['country'])) : false;
$id_state = $id_country ? State::getIdByIso($attributes['iso_code'], $id_country) : State::getIdByName($attributes['name']);
if (!$id_state) {
$state = new State();
$state->name = strval($attributes['name']);
$state->iso_code = strval($attributes['iso_code']);
$state->id_country = $id_country;
$id_zone = (int) Zone::getIdByName(strval($attributes['zone']));
if (!$id_zone) {
$zone = new Zone();
$zone->name = (string) $attributes['zone'];
$zone->active = true;
if (!$zone->add()) {
$this->_errors[] = Tools::displayError('Invalid Zone name.');
return false;
}
$id_zone = $zone->id;
}
$state->id_zone = $id_zone;
if (!$state->validateFields()) {
$this->_errors[] = Tools::displayError('Invalid state properties.');
return false;
}
$country = new Country($state->id_country);
if (!$country->contains_states) {
$country->contains_states = 1;
if (!$country->update()) {
$this->_errors[] = Tools::displayError('Cannot update the associated country: ') . $country->name;
}
}
if (!$state->add()) {
$this->_errors[] = Tools::displayError('An error occurred while adding the state.');
return false;
}
} else {
$state = new State($id_state);
if (!Validate::isLoadedObject($state)) {
$this->_errors[] = Tools::displayError('An error occurred while fetching the state.');
return false;
}
}
}
}
return true;
}
示例3: Zone
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
require_once "pre.php";
require_once "auth.php";
if (!est_autorise("acces_configuration")) {
exit;
}
require_once "../fonctions/divers.php";
require_once "liste/zone.php";
if ($_POST['action'] == "ajouter" && $_POST['nomzone'] != "") {
$zone = new Zone();
$zone->nom = $_POST['nomzone'];
$id = $zone->add();
} else {
if ($_GET['action'] == "supprimer" && $_GET['id'] != "") {
$zone = new Zone();
$pays = new Pays();
$query = "update {$pays->table} set zone=\"-1\" where zone=\"" . $_GET['id'] . "\"";
$resul = mysql_query($query, $pays->link);
$zone->charger($_GET['id']);
$zone->delete();
}
}
if ($_REQUEST['id'] != "") {
$id = $_REQUEST['id'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
示例4: importZones
protected function importZones()
{
$this->truncateTables(array('zone', 'zone_shop'));
$handle = $this->openCsvFile('zones.csv');
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
$res = false;
$fields = $this->filterFields('Zone', $this->zones_fields, $line);
if (!isset($fields['id_zone'])) {
$zone = new Zone($line[0]);
$zone->id = $line[0];
} else {
$zone = new Zone($fields['id_zone']);
}
foreach ($fields as $key => $field) {
$zone->{$key} = $field;
}
$zone->force_id = true;
if (!$res) {
$res = $zone->add();
}
}
$this->closeCsvFile($handle);
return true;
}