CodeIgniter Forums
Help with updating to 3.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forum-9.html)
+--- Thread: Help with updating to 3.0 (/thread-1154.html)



Help with updating to 3.0 - MattafixTM - 02-15-2015

Hello dear users.
The help with the codeigniter updating to 3.0 is necessary
Screenshots of mistakes:
http://prntscr.com/65d7a9
http://prntscr.com/65d7hw
http://prntscr.com/65d7rb

I didn't understand documentation, the weak level of English. A sort from Russia.
The big gratitude who will undertake to help me!

Forgive for English


RE: Help with updating to 3.0 - MattafixTM - 02-15-2015

I updated the link to a script.


RE: Help with updating to 3.0 - rocks - 02-15-2015

(02-15-2015, 05:37 AM)MattafixTM Wrote: Hello dear users.
The help with the codeigniter updating to 3.0 is necessary
Screenshots of mistakes:
http://prntscr.com/65d7a9
http://prntscr.com/65d7hw
http://prntscr.com/65d7rb

I didn't understand documentation, the weak level of English. A sort from Russia.
The big gratitude who will undertake to help me!

Link to a script: http://goo.gl/UJK6Y4

Forgive for English
I translated the translator of http://translate.com

Nobody wants to download your code..
Provide some in here and surely people will help.


RE: Help with updating to 3.0 - mwhitney - 02-16-2015

I'm not sure how much it's going to help if you're having trouble understanding the PHP errors themselves, but I'll attempt the first couple of items:

Quote:Message: Declaration of Siteconfig:: save() should be compatible with that of MY_Model:: save()

This shouldn't have anything to do with the upgrade from CI 2 to 3. This implies that you changed something in MY_Model's save() method (like the number/type of arguments) without making the equivalent changes in Siteconfig's save() method.

Quote:Message: Undefined property: CI_DB_mysqli_driver:: $ar_orderby
Filename: core/MY_Model.php
In this case, your MY_Model is referencing a private property in the mysqli driver for Active Record. Since Active Record has changed to Query Builder, the name of the property also changed. Since the property was private and the visibility indicators have been added to the code, it is no longer accessible. You're going to have to rewrite your MY_Model so that it no longer depends on the availability of this property.


RE: Help with updating to 3.0 - MattafixTM - 02-19-2015

Don't have a lot about this, if you can help please. I would be very grateful.
PHP Code:
<?php

class MY_Model extends CI_Model {

 protected 
$table_name '';
 protected 
$primary_key 'id';
 protected 
$primary_filter 'intval';
 protected 
$order_by '';
 protected 
$rules = array();
 protected 
$timestamps FALSE;
 
 function 
__Construct() {
 
// Call the CI_Model constructor
 
       parent::__construct();
 
   }
 
 public function 
get($id NULL$single FALSE) {
 if(
$id != NULL) {
 
$filter $this->primary_filter;
 
$id $filter($id);
 
$this->db->where($this->primary_key,$id);
 
$method 'row';
 }
 elseif(
$single == TRUE) {
 
$method 'row';
 }
 else {
 
$method 'result';
 }
 if(!
count($this->db->ar_orderby)) {
 
$this->db->order_by($this->order_by);
 }
 return 
$this->db->get($this->table_name)->$method();
 }
 
 public function 
get_by($where$single FALSE) {
 
$this->db->where($where);
 return 
$this->get(NULL,$single);
 }
 
 public function 
save($data$id NULL) {
 if(
$this->timestamps == TRUE) {
 
$now date('Y-m-d H:i:s');
 
$id || $data['created'] = $now;
 
$data['modified'] = $now;
 }
 
 if(
$id === NULL) {
 !isset(
$data[$this->primary_key]) || $data[$this->primary_key] = NULL;
 
$this->db->set($data);
 
$this->db->insert($this->table_name);
 
$id $this->db->insert_id();
 }
 else {
 
$filter $this->primary_filter;
 
$id $filter($id);
 
$this->db->set($data);
 
$this->db->where($this->primary_key,$id);
 
$this->db->update($this->table_name);
 }
 return 
$id;
 }
 
 public function 
delete($id) {
 
$filter $this->primary_filter;
 
$id $filter($id);
 
 if(!
$id) {
 return 
FALSE;
 }
 
 
$this->db->where($this->primary_key,$id);
 
$this->db->limit(1);
 
$this->db->delete($this->table_name);
 } 
 
 public function 
array_from_post($fields){
 
   $data = array();
 
   foreach ($fields as $field) {
 
       $data[$field] = $this->input->post($field);
 
   }
 
   return $data;
 }
}

?>

Siteconfig
PHP Code:
<?php

$router 
= &load_class('Router''core');
$dir $router->fetch_directory();

class 
Siteconfig extends MY_Model {
    public 
$rules = array(
    
'site_name' => array('field' => 'site_name''label' => 'Название сайта''rules' => 'trim'),
    
'sitedescription' => array('field' => 'sitedescription''label' => 'Фраза под заголовком''rules' => 'trim|max_length[255]'),
    
'metadescr' => array('field' => 'metadescr''label' => 'Мета-описание сайта''rules' => 'trim'),
    
'yad_client_id' => array('field' => 'yad_client_id''label' => 'Яндекс(Client ID)''rules' => 'trim'),
    
'yad_token' => array('field' => 'yad_token''label' => 'Яндекс(Token)''rules' => 'trim'),
    
'qiwi_num' => array('field' => 'qiwi_num''label' => 'QIWI(Номер без +)''rules' => 'trim'),
    
'qiwi_pass' => array('field' => 'qiwi_pass''label' => 'QIWI(Пароль)''rules' => 'trim'),
    
'wmid' => array('field' => 'wmid''label' => 'wmid''rules' => 'integer|trim|xss_clean'),
    
'WMR' => array('field' => 'WMR''label' => 'WMR''rules' => 'trim|xss_clean'),
    
'WMZ' => array('field' => 'WMZ''label' => 'WMZ''rules' => 'trim|xss_clean'),
    
'wm_pass' => array('field' => 'WMZ''label' => 'WMZ''rules' => 'trim'),
    );
    
    function 
__construct() {
        
// Call the CI_Model constructor
        
parent::__construct();
    }

    public function 
get_all() {
        return 
$this->db->get('config_data');
    }

    public function 
update_config($data) {
        
$success '0';
        foreach (
$data as $key => $value) {

            if (!
$this->save($key$value)) {
                
$success '1';
                break;
            }
        }

        return 
$success;
    }

    public function 
save($key$value) {
        
$config_data = array('key' => $key'value' => $value);
        
$this->db->where('key'$key);
        return 
$this->db->update('config_data'$config_data);
    }
}

?>



RE: Help with updating to 3.0 - MattafixTM - 02-22-2015

Somebody will help?


RE: Help with updating to 3.0 - dbui - 02-22-2015

Hi there

Your model got error with the first error

function __Construct() {
// Call the CI_Model constructor
parent::__construct();
}

change __Construct to __construct() as I think you need class name to be Upper in first letter not the function per CI 3.0

Try that fix then you should see the list gets less errors then go further


RE: Help with updating to 3.0 - MattafixTM - 02-23-2015

(02-22-2015, 11:06 PM)dbui Wrote: Hi there

Your model got error with the first error

function __Construct() {
// Call the CI_Model constructor
       parent::__construct();
   }

change __Construct to __construct() as I think you need class name to be Upper in first letter not the function per CI 3.0

Try that fix then you should see the list gets less errors then go further
That's not the point.


RE: Help with updating to 3.0 - mwhitney - 02-24-2015

MY_Model:
Quote:public function save($data, $id = NULL) {
Siteconfig:
Quote:public function save($key, $value) {

The second one has to be compatible with the first, meaning Siteconfig:Confusedave() must have a default value on the second argument.

The comment made by dbui earlier about the name of the __construct method should be addressed as well.