Welcome Guest, Not a member yet? Register   Sign In
Database problems. mysql/mysqli/pdo
#1

Hi! 
i wrote an easy script in CI for testing db access...
using mysql driver it works, but it shows a warning message

Code:
A PHP Error was encountered

Severity: 8192

Message: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

Filename: mysql/mysql_driver.php

Line Number: 135

Backtrace:

File: /web/htdocs/www.plickapp.com/home/API/index.php
Line: 315
Function: require_once

i've tried to use it with mysqli or pdo but without results...
Somebody can help me?


Controller - View_events.php
PHP Code:
<?php if ( ! defined('BASEPATH'))exit('No direct script access allowed');


class 
View_events extends CI_Controller
{
    public function amichevolmente($a =false)
    {
        $data = array();
        $data['saluta_a'] = $a;
        
        
//$this->load->view('stampa_eventi',$data);
        echo "prova";
    }
    
    
public function stampa_eventi()
    {
        //$this->load->database(); 
        
$this->load->model('Eventi_model');
        
$data=$this->Eventi_model->getEventi();
        echo 
$data;
    }
    


Model - Eventi_model.php
PHP Code:
<?php
class Eventi_model extends CI_Model {


    function __construct()
    {
        parent::__construct();
    }
    
    
function getEventi()
    {
       
        $query
=$this->db->get('events');
       
       if
($query->num_rows 1) 
           
return "NO";
       else
           
return "SI";
       
       
//echo "eventi";
    }


}
  

and the mysql config 
Code:
$db['default'] = array(
    'dsn'    => '',
    'hostname' => 'DB_ADDRESS',
    'username' => 'DB_USERNAME',
    'password' => '*********',
    'database' => 'Sql1138857_1',
    'dbdriver' => 'mysql',
    'dbprefix' => '',
    'pconnect' => TRUE,
    'db_debug' => TRUE, //(ENVIRONMENT !== 'production')
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE

i've already tried to change "mysql" in "mysqli" in dbdriver.. and it doesn't work.
using pdo config (dsn) i have the samre result.
Reply
#2

Define what you mean by "doesn't work".
Reply
#3

(10-04-2017, 07:42 AM)Narf Wrote: Define what you mean by "doesn't work".

I'm sorry.
how you can see in model
Code:
if($query->num_rows < 1)
          return "NO";
      else
          return "SI";
using mysql the echo is "SI",
with mysqli and PDO is "NO".
the table is so easy and i've tried also to use 
$query=$this->db->query('MY_QUERY');
instead of $query=$this->db->get('events');
Reply
#4

You should be using num_rows() - the method, not a property.
Reply
#5

(10-04-2017, 10:15 AM)Narf Wrote: You should be using num_rows() - the method, not a property.

omg... i'm feeling so stupid... It works...
thanks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB