Welcome Guest, Not a member yet? Register   Sign In
I found issue with db driver
#1

I am using pdo driver and my query is
PHP Code:
$query $this->db->select()->from('community_list')->where('community_name',$community);
        
$rows $query->num_rows(); 

Its show me error like

Code:
Severity: Notice

Message: Array to string conversion

Filename: database/DB_query_builder.php

Line Number: 662
Reply
#2

And Also for this query
PHP Code:
$c = array(
'community' => $community
);
$query $this->db->get_where('community_list'$c); 
Reply
#3

Have you done a var_dump on $community .. maybe you have wrong data.

Reply
#4

No. its not.
Reply
#5

(This post was last modified: 02-15-2015, 01:27 AM by twpmarketing. Edit Reason: syntax correction )

Vimal,
 The syntax of the where() clause is the problem.
From the User Guide (v. 3.0):

http://www.codeigniter.com/userguide3/da...cific-data

You can pass an associative array directly in the where() clause.  However your code assigns an variable ($community) to a column name ('community_name').  Because the column type is probably string, the error is generated when you assign an array ($community) to that string var.


Code:
where('community_name',$community)

I think you want to use either the  where_in() OR or_where_in() clause.  They are explained a few paragraphs below the User Guide link above.  Note that the array is NOT associative in this usage.

Quote:$this->db->or_where_in()


Generates a WHERE field IN (‘item’, ‘item’) SQL query joined with OR if appropriate

$names = array('Frank', 'Todd', 'James');
$this->db->or_where_in('username', $names);

// Produces: OR username IN ('Frank', 'Todd', 'James')
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB