$query=$this->db->get()->result_array(); //直接写sql $sql="SELECT * FROM category WHERE is_show = ? "; $query=$this->db->query($sql,array(1)); echo$query->result_id; var_dump($query); return$query->result_array();
The parameter (false) in the first query below enables you to set whether or not the query builder will be reset (because the default value of the parameter is true, getCompiledSelect(bool $reset = true), by default it will be reset just like when using ...
Fix BaseBuilder setAlias() and RawSql use with key value pairs by @sclubricants in #6741 fix: BasePreparedQuery class to return boolean values for write-type queries by @michalsn in #6750 fix: Time::now() does not respect timezone when using setTestNow() by @kenjis in #6752 fix: ...
The first parameter is the table name, the second is an associative array with the data to be updated, and the third parameter is the “where” clause. The above example produces:UPDATE table_name SET name = 'Rick', email = '[email protected]', url = 'example.com' WHERE author_id ...
It will allow the Query Builder to surround table names and column names with backticks when TRUE Library no longer enforces POST requests. POST or GET can be used now v1.2 New Method setProtectIdentifiers(boolean) this defaults to FALSE if not specified. It will allow the Query Builder...
If you'd like to return results as array you can:either define $this->return_as = 'array' in the constructor or add as_array() into the query chain:$users = $this->user_model->as_array()->get_all(); $posts = $this->post_model->as_object()->get_all();...
This function allows you to write the LIKE portion of your query, and functions in almost the exact same way as the where() method. Single key or value method This method is the same as the where() method, when used as follows:1 $this->db->like('name', $name); Multiple...
$query = $this->db->query("SELECT * FROM mytable"); // Turn caching off for this one query $this->db->cache_off(); $query = $this->db->query("SELECT * FROM members WHERE member_id = '$current_user'"); // Turn caching back on ...
$where_clause: (optional) This is the where statement in case you need to specify an extra where statement to the query of relations.Example:function film_management() { $crud = new grocery_CRUD(); $crud->set_table('film'); $crud->set_relation_n_n('actors', 'film_actor', 'actor...
$where = "author_id = 1 AND status = 'active'"; $str = $this->db->update_string('table_name', $data, $where); The first parameter is the table name, the second is an associative array with the data to be updated, and the third parameter is the "where" clause. The above exam...