Just contact CI, to manipulate the database has not found the right way.
Environment: Wampserver CI
Problem: Query the data from the table in the phpMyAdmin, error:
1,Message:object of class Ci_db_mysqli_result could not being converted to string"
2.Message:array to string conversion
3,message:syntax error, unexpected ' name ' (t_constant_encapsed_string), expect t_constant_ Encapsed_string
Reason:
There are many types of data stored in the database, you want to take the type of data, the environment does not necessarily support, so PHP and MySQL communication between the full use of string.
and $query= $this->db->query ($sql); The data returned is type object. To remove the results from the $query and query by field. The specific code is shown below.
<?php
class Dbtest extends ci_controller{public
function Index () {
echo ' What a good day! ';
}
Public Function Dbcon () {
$this->load->database ();
$sql = "SELECT * from Clientcount where ID =3";
$query = $this->db->query ($sql);
if (! $this->db->simple_query ($sql))
{
$error = $this->db->error ();
}
if ($query->num_rows () >0) {
$result = $query->result ();
foreach ($result as $row)
{
echo $row->id;
echo $row->name;
}
}
Else{
echo False}
}
? >