Array to string conversion [Réglé]
MrToine Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre MrToine
- Inscrit le : 26/10/2014
- Groupes :
J'ai une erreur lors de l'édition d'un partenaire sur mon module : Array to string conversion. Je voit bien ce que l'erreur veut dire mais je ne comprends pas ou ça cloche. Voici le rapport d'erreur avec les codes utilisés pour cette page :
Rapport d'erreur
Code TEXT :
Notice : Array to string conversion [0] /partners/services/PartnersService.class.php:56 [0] /partners/controllers/AdminPartnersEditController.class.php:123 - PartnersService::get_partner(string, array) [1] /partners/controllers/AdminPartnersEditController.class.php:37 - AdminPartnersEditController->get_partner() [2] /kernel/framework/mvc/dispatcher/UrlControllerMapper.class.php:87 - AdminPartnersEditController->execute(HTTPRequestCustom) [3] /kernel/framework/mvc/dispatcher/UrlControllerMapper.class.php:59 - UrlControllerMapper->do_call() [4] /kernel/framework/mvc/dispatcher/Dispatcher.class.php:67 - UrlControllerMapper->call() [5] /kernel/framework/mvc/dispatcher/DispatchManager.class.php:43 - Dispatcher->dispatch() [6] /partners/index.php:46 - DispatchManager::dispatch(array) [URL] /developpement/phpboost-4/partners/edit/1
AdminPartnersEditController.class.php
Code PHP :
<?php /*################################################## * PartnersAddController.class.php * ------------------- * begin : November 02, 2014 * copyright : (C) 2014 Anthony VIOLET * email : anthony.violet@outlook.fr * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class AdminPartnersEditController extends AdminModuleController { private $view, $lang, $partner, $submit_button; public function execute(HTTPRequestCustom $request) { $this->get_partner(); $this->init(); $form = $this->build_form(); if ($this->submit_button->has_been_submited()) { if ($form->validate()) { $result = PersistenceContext::get_querier()->insert(PREFIX.'partners', array( 'name' => $form->get_value('name'), 'link' => $form->get_value('link'), 'link_banner' => $form->get_value('link_banner'), 'description' => $form->get_value('description'), 'ip_adress' => $_SERVER['REMOTE_ADDR'] )); $this->view->put_all(array( 'C_RESULT' => true, 'PARTNER' => $result, 'ADD_SUCCESS' => $this->lang['add_success'], 'ADD_NOTICE' => $this->lang['add_notice'], 'LINK_ENTRY' => $this->lang['link_entry'], 'LINK_MY_BANNER' => $this->lang['link_my_banner'], 'CODE_LINK' => '<div class="notice">'.htmlspecialchars('<a href="'.$this->lang['link_entry'].$result->get_last_inserted_id().'"><img src="'.$this->lang['link_my_banner'].'" /></a>').'</div>' )); } } $this->view->put_all(array( 'ADD_MESSAGE' => $this->lang['add_message'], )); $this->view->put('form', $form->display()); return $this->generate_response(); } private function init() { $this->lang = LangLoader::get('common', 'partners'); $this->view = new FileTemplate('partners/PartnersEditController.tpl'); $this->view->add_lang($this->lang); } private function build_form() { $form = new HTMLForm('PartnersForm'); // FIELDSET $fieldset = new FormFieldsetHTML('fieldset', 'Devenir Partenaire'); $form->add_fieldset($fieldset); // INFOS $fieldset->add_field(new FormFieldTextEditor('name', $this->lang['form_name'], '', array( 'maxlength' => 25, 'description' => $this->lang['form_name_desc'], 'required' => true) )); $fieldset->add_field(new FormFieldTextEditor('link', $this->lang['form_link'], '', array( 'maxlength' => 255, 'description' => $this->lang['form_link_desc'], 'required' => true), array(new FormFieldConstraintUrl()) )); $fieldset->add_field(new FormFieldTextEditor('link_banner', $this->lang['form_link_banner'], '', array( 'maxlength' => 255, 'description' => $this->lang['form_link_banner_desc'], 'required' => true), array(new FormFieldConstraintUrl()) )); // DESCRIPTION $fieldset->add_field(new FormFieldRichTextEditor('description', $this->lang['form_description'], '')); // BUTTONS $buttons_fieldset = new FormFieldsetSubmit('buttons'); $this->submit_button = new FormButtonDefaultSubmit(); $buttons_fieldset->add_element($this->submit_button); $form->add_fieldset($buttons_fieldset); return $form; } private function get_partner() { $partner_id = AppContext::get_request()->get_getint('partner_id'); $this->partner = PartnersService::get_partner('WHERE id=:id', array('id' => $partner_id)); return $this->partner; } private function generate_response() { $response = new SiteDisplayResponse($this->view); $graphical_environment = $response->get_graphical_environment(); $graphical_environment->set_page_title($this->lang['module_title']); $breadcrumb = $graphical_environment->get_breadcrumb(); $breadcrumb->add($this->lang['module_title'], PartnersUrlBuilder::home()->rel()); $breadcrumb->add($this->lang['add_page'], PartnersUrlBuilder::add()->rel()); return $response; } }
PartnersService.class.php
Code PHP :
<?php /*################################################## * PartnersService.class.php * ------------------- * begin : October 27, 2014 * copyright : (C) 2014 Anthony VIOLET * email : anthony.violet@outlook.fr * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class PartnersService { private static $db_querier; private static $partners_manager; public static function __static() { self::$db_querier = PersistenceContext::get_querier(); } public static function add(Partner $partner) { $result = self::$db_querier->insert(PartnersSetup::$partners_table, $partner->get_properties()); return $result->get_last_inserted_id(); } public static function update(Article $article) { self::$db_querier->update(PartnersSetup::$partners_table, $partners->get_properties(), 'WHERE id=:id', array('id', $partners->get_id())); } public static function delete($condition, array $parameters) { self::$db_querier->delete(PartnersSetup::$partners_table, $condition, $parameters); } public static function get_partner($condition, array $parameters) { $row = self::$db_querier->select_single_row_query('SELECT * FROM '.PartnersSetup::$partners_table.' '.$condition.' '.$parameters); $partner = new Partner(); $partner->set_properties($row); return $partner; } } ?>
Partner.class.php
Code PHP :
<?php /*################################################## * Partner.class.php * ------------------- * begin : October 31, 2014 * copyright : (C) 2014 Anthony VIOLET * email : anthony.violet@outlook.fr * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class Partner { private $_id, $_name, $_mail, $_description, $_link, $_link_banner, $_entries, $_outputsputs; public function get_id(){ return $this->_id; } public function get_name(){ return $this->_name; } public function get_mail(){ return $this->_mail; } public function get_desccription(){ return $this->_description; } public function get_link(){ return $this->_link; } public function get_link_banner(){ return $this->_link_banner; } public function get_entries(){ return $this->_entries; } public function get_outputs(){ return $this->_outputs; } public function set_id($id){ $id = (int) $id; if($id > 0){ $this->_id = $id; } } public function set_name($name){ if(is_string($name)){ $this->_name = htmlspecialchars($name); } } public function set_mail($mail) { if(is_string($mail)){ $this->_mail = htmlspecialchars($mail); } } public function set_description($description){ $this->_description = htmlspecialchars($description); } public function set_link($link){ $this->_link = htmlspecialchars($link); } public function set_link_banner($link_banner){ $this->_link_banner = htmlspecialchars($link_banner); } public function set_entries($entries){ $entries = (int) $entries; if(is_int($entries)){ $this->_entries = htmlspecialchars($entries); } } public function set_outputs($outputs){ $outputs = (int) $outputs; if(is_int($outputs)){ $this->_outputs = htmlspecialchars($outputs); } } public function get_properties() { return array( 'id' => $this->get_id(), 'name' => TextHelper::htmlspecialchars($this->get_name()), 'mail' => TextHelper::htmlspecialchars($this->get_mail()), 'description' => TextHelper::htmlspecialchars($this->get_description()), 'link' => TextHelper::htmlspecialchars($this->get_link()), 'link_banner' => TextHelper::htmlspecialchars($this->get_link_banner()), 'entries' => (int) $this->get_entries(), 'outputs' => (int) $this->get_outputs() ); } public function set_properties(array $properties) { $this->_id = $properties['id']; $this->_name = $properties['name']; $this->_mail = $properties['mail']; $this->_description = $properties['description']; $this->_link = $properties['link']; $this->_link_banner = $properties['link_banner']; $this->_entries = $properties['entries']; $this->_outputs = $properties['outputs']; } public function get_array_tpl_vars() { return array( 'ID' => $this->_id, 'NAME' => $this->_name, 'MAIL' => $this->_mail, 'DESCRIPTION' => $this->_description, 'LINK' => $this->_link, 'LINK_BANNER' => $this->_link_banner, 'ENTRIES' => $this->_entries, 'OUTPUTS' => $this->_outputs, ); } }
MrToine Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre MrToine
- Inscrit le : 26/10/2014
- Groupes :
j1.seth Membre non connecté
-
Administrateur
- Voir le profil du membre j1.seth
- Inscrit le : 01/09/2008
- Site internet
- Groupes :
-
Chef de Projet
-
Equipe Développement
Remplaces la ligne 56 de PartnersService.class.php par :
Code PHP :
$row = self::$db_querier->select_single_row_query('SELECT * FROM '.PartnersSetup::$partners_table.' '.$condition, $parameters);
MrToine Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre MrToine
- Inscrit le : 26/10/2014
- Groupes :
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie