Welcome Guest, Not a member yet? Register   Sign In
Mysql start-complete
#1

(This post was last modified: 12-16-2016, 03:23 AM by Marcel.)

Hi all .

could someone please tell me if this is good code for mysql.

PHP Code:
function get_cities_from_id$cityid )
 
   {
 
       $this->db->select'
          app_cities.city_id,
          app_cities.city_fr ,
          app_cities.city_zip,
          app_cities.city_latitude,
          app_cities.city_longitude' 
);
 
       $this->db->from'app_cities' );
 
       $this->db->where'city_id'$cityid );
 
       $this->db->trans_start();
 
       $this->db->trans_complete();
 
       $result $this->db->get();
 
       if $result->num_rows() > ):
 
           return $result->first_row();
 
       else:
 
           return false;
 
       endif;
 
   

thanks alot.
Reply
#2

You only need the trans_start and trans_complete functions if you want to update or insert records in multiple tables. If one of the updates or inserts fails, the entire transaction will be rolled back.
If you retrieve records by a unique ID, the result can only be one record (row).
PHP Code:
return $result->row(); 
will do.
Reply
#3

(12-16-2016, 03:55 AM)Wouter60 Wrote: You only need the trans_start and trans_complete functions if you want to update or insert records in multiple tables. If one of the updates or inserts fails, the entire transaction will be rolled back.
If you retrieve records by a unique ID, the result can only be one record (row).
PHP Code:
return $result->row(); 
will do.

ok thanks alot for the info ill surely be back Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB