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

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

Severity: Notice

Message: Array to string conversion

Filename: database/DB_query_builder.php

Line Number: 662

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

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


No. its not.

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

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


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.


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.


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.

Theme © iAndrew 2016 - Forum software by © MyBB