Search Results

Search found 981 results on 40 pages for 'codeigniter 2'.

Page 10/40 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Codeigniter Pagination: Run the Query Twice?

    - by Frank
    I'm using codeigniter and the pagination class. This is such a basic question, but I need to make sure I'm not missing something. In order to get the config items necessary to paginate results getting them from a MySQL database it's basically necessary to run the query twice is that right? In other words, you have to run the query to determine the total number of records before you can paginate. So I'm doing it like: Do this query to get number of results $this->db->where('something', $something); $query = $this->db->get('the_table_name'); $num_rows = $query->num_rows(); Then I'll have to do it again to get the results with the limit and offset. Something like: $this->db->where('something', $something); $this->db->limit($limit, $offset); $query = $this->db->get('the_table_name'); if($query->num_rows()){ foreach($query->result_array() as $row){ ## get the results here } } I just wonder if I'm actually doing this right in that the query always needs to be run twice? The queries I'm using are much more complex than what is shown above.

    Read the article

  • Losing URI segments when paginating with CodeIgniter

    - by Danny Herran
    I have a /payments interface where the user should be able to filter via price range, bank, and other stuff. Those filters are standard select boxes. When I submit the filter form, all the post data goes to another method called payments/search. That method performs the validation, saves the post values into a session flashdata and redirects the user back to /payments passing the flashdata name via URL. So my standard pagination links with no filters are exactly like this: payments/index/20/ payments/index/40/ payments/index/60/ And if you submit the filter form, the returning URL is: payments/index/0/b48c7cbd5489129a337b0a24f830fd93 This works just great. If I change the zero for something else, it paginates just fine. The only issue however is that the << 1 2 3 4 page links wont keep the hash after the pagination offset. CodeIgniter is generating the page links ignoring that additional uri segment. My uri_segment config is already set to 3: $config['uri_segment'] = 3; I cannot set the page offset to 4 because that hash may or may not exists. Any ideas of how can I solve this? Is it mandatory for CI to have the offset as the last segment in the uri? Maybe I am trying an incorrect approach, so I am all ears. Thank you folks.

    Read the article

  • SQL to CodeIgniter Array Missing Data Issue

    - by SamD
    $query = $this->db->query("SELECT t1.numberofbets, t1.profit, t2.seven_profit, t3.28profit, user.user_id, username, password, email, balance, user.date_added, activation_code, activated FROM user LEFT JOIN (SELECT user_id, SUM(amount_won) AS profit, count(tip_id) AS numberofbets FROM tip GROUP BY user_id) as t1 ON user.user_id = t1.user_id LEFT JOIN (SELECT user_id, SUM(amount_won) AS seven_profit FROM tip WHERE date_settled > '$seven_daystime' GROUP BY user_id) as t2 ON user.user_id = t2.user_id LEFT JOIN (SELECT user_id, SUM(amount_won) AS 28profit FROM tip WHERE date_settled > '$twoeight_daystime' GROUP BY user_id) as t3 ON user.user_id = t3.user_id where activated = 1 GROUP BY user.user_id ORDER BY user.date_added DESC"); return $query->result_array(); The query works fine running it in phpMyAdmin and returns complete results (in image attached). However, printing the array in CodeIgniter, it has no value for one field ,seven_profit, where it is there in the SQL query ran in phpMyAdmin, just the discrepancy in this one field, from sql to php array... I just can’t see why, when printing the array, that one field, which should have value of 26, contains nothing? Any ideas? I changed the field name from starting with a number in attempt to fix it, but no difference. I know this is complex and looks horrible, any help or just people coming across something similar would be great to know about, thanks. Sam

    Read the article

  • Formating a table date field from the Model in Codeigniter

    - by Landitus
    Hi, I', trying to re-format a date from a table in Codeigniter. The Controller is for a blog. I was succesfull when the date conversion happens in the View. I was hoping to convert the date in the Model to have things in order. Here's the date conversion as it happens in the View. This is inside the posts loop: <?php foreach($records as $row) : ?> <?php $fdate = "%d <abbr>%M</abbr> %Y"; $dateConv = mdate($fdate, mysql_to_unix($row->date)); ?> <div class="article section"> <span class="date"><?php echo $dateConv ;?></span> ... Keeps going ... This is the Model: class Novedades_model extends Model { function getAll() { $this->db->order_by('date','desc'); $query = $this->db->get('novedades'); if($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } } return $data; } } How can I convert the date in the Model? Can I access the date key and refactor it?

    Read the article

  • Codeigniter return config file as array with autoload enabled

    - by Fverswijver
    So I'm using CodeIgniter to build a website and I've made it so that all my specific settings are stored in a config file that's automatically loaded. I've also built a page that loads the settings file, makes a nice little table and allows me to edit everything from that page, afterwards it saves the entire page again (I know I could've done the same with a database but I want to try it this way). My problem is that I can't seem to use this bit when autoloading of my config file is enabled, but when I disable autoloading I can't seem to manually load it, it never finds my variables. So what I'm doing here is just taking all values from the config file and putting them in a single array so I can pass this array onto my settings administration page (edit/show all settings). $this->config->load('site_settings', TRUE); $data['settings'] = $this->config->item('site_settings'); ... $this->load->view('template', $data); config/site_settings.php <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $config['header_img'] = './img/header/'; $config['copyright_text'] = 'Copyright Instituto Kabu'; $config['copyright_font'] = './system/fonts/motoroil.ttf'; $config['copyright_font_color'] = 'ffffff'; $config['copyright_font_size'] = '32';

    Read the article

  • codeigniter active record and mysql

    - by sea_1987
    I am running a query with Active Record in a modal of my codeigniter application, the query looks like this, public function selectAllJobs() { $this->db->select('*') ->from('job_listing') ->join('job_listing_has_employer_details', 'job_listing_has_employer_details.employer_details_id = job_listing.id', 'left'); //->join('employer_details', 'employer_details.users_id = job_listing_has_employer_details.employer_details_id'); $query = $this->db->get(); return $query->result_array(); } This returns an array that looks like this, [0]=> array(13) { ["id"]=> string(1) "1" ["job_titles_id"]=> string(1) "1" ["location"]=> string(12) "Huddersfield" ["location_postcode"]=> string(7) "HD3 4AG" ["basic_salary"]=> string(19) "£20,000 - £25,000" ["bonus"]=> string(12) "php, html, j" ["benefits"]=> string(11) "Compnay Car" ["key_skills"]=> string(1) "1" ["retrain_position"]=> string(3) "YES" ["summary"]=> string(73) "Lorem Ipsum is simply dummy text of the printing and typesetting industry" ["description"]=> string(73) "Lorem Ipsum is simply dummy text of the printing and typesetting industry" ["job_listing_id"]=> NULL ["employer_details_id"]=> NULL } } The job_listing_id and employer_details_id return as NULL however if I run the SQL in phpmyadmin I get full set of results, the query i running in phpmyadmin is, SELECT * FROM ( `job_listing` ) LEFT JOIN `job_listing_has_employer_details` ON `job_listing_has_employer_details`.`employer_details_id` LIMIT 0 , 30 Is there a reason why I am getting differing results?

    Read the article

  • Codeigniter Inserting Multidimensional Array as rows in MySQL

    - by RisingSun
    Please Refer to this question I asked Codeigniter Insert Multiple Rows in SQL To restate <tr> <td><input type="text" name="user[0][name]" value=""></td> <td><input type="text" name="user[0][address]" value=""><br></td> <td><input type="text" name="user[0][age]" value=""></td> <td><input type="text" name="user[0][email]" value=""></td> </tr> <tr> <td><input type="text" name="user[1][name]" value=""></td> <td><input type="text" name="user[1][address]" value=""><br></td> <td><input type="text" name="user[1][age]" value=""></td> <td><input type="text" name="user[1][email]" value=""></td> </tr> .......... Can Be Inserted into MySQL as this foreach($_POST['user'] as $user) { $this->db->insert('mytable', $user); } This results in multiple MySQL queries. Is it possible to optimise it further, so that the insert occurs in one query Something like this insert multiple rows via a php array into mysql but taking advantage of codeigniters simpler syntax. Thanks

    Read the article

  • Codeigniter - change url at method call

    - by NemoPS
    I was wondering if the following can be done in codeigniter. Let's assume I have a file, called Post.php, used to manage posts in an admin interface. It has several methods, such as index (lists all posts), add, update, delete... Now, I access the add method, so that the url becomes /posts/add And I add some data. I click "save" to add the new post. It calls the same method with an if statement like "if "this-input-post('addnew')"" is passed, call the model, add it to the database Here follows the problem: If everything worked fine, it goes to the index with the list of all posts, and displays a confirmation BUT No the url would still be posts/add, since I called the function like $this-index() after verifying data was added. I cannot redirect it to "posts/" since in that case no confirmation message would be shown! So my question is: can i call a method from anther one in the same class, and have the url set to that method (/posts/index instead of /posts/add)? It's kinda confusing, but i hope i gave you enough info to spot the problem Cheers!

    Read the article

  • minifying final html output using regex with codeigniter

    - by Aman
    Google pages suggest you to minify html i.e. remove all the un-necessary spaces. Codeigniter does have feature of giziping output or it can be done via .htaccess. But still I also would like to remove un-necessary spaces from final html output as well. I played a bit with this peace of code to do it, and it seem to work. This does indeed result in html that is without excess spaces and removes other tab formatting. class Welcome extends CI_Controller { function _output() { echo preg_replace('!\s+!', ' ', $output); } function index(){ ... } } Now the problem with this is there may be tag like <pre>,<textarea>, etc.. which may have space in it and regx should remove them. So, how do I remove excess space from final html, without effecting spaces or formatting for these certain tags using regx? Thanks to @Alan Moore got the answer, this worked for me echo preg_replace('#(?ix)(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:textarea|pre)\b))*+)(?:<(?>textarea|pre)\b|\z))#', ' ', $output); @ridgerunner here did very good job of analyzing this regx, ended up using his solution. Cheers to ridgerunner.

    Read the article

  • CodeIgniter - Image Validation & Thumbnailing

    - by Sebhael
    I'm currently trying to create a function that validates and creates thumbnails for images on upload - but I'm quite lost on what I'm doing. I'm assuming I'm off on my terminology so I'm not really getting any search results to help point me in the right direction. My playground is a form with 6 upload fields that are required. One of these fields is for a simple 32x32 icon image, another a portrait orientation (most likely) photo, and then 4 standard desktop screenshots -- and I'm using CodeIgniter as my framework. I would like to create a function that validates/thumbnails images, and only have to call it on the validation if at all possible. I know I can achieve this per-image, since the documentation for CI is quite through on this - but to reduce redundancy I'm looking for the better option. Outside of that, I don't even actually understand in full how to manipulate images unless it's just $this-input-post('field') - then calling all functions onto this? I don't know, I'm confused and posting on the actual CI forums has yielded me nothing - so all I'm really looking for is a point in the right direction to understanding what I'm trying to achieve here. This also all might not make any sense, I know it doesn't to me - but I can explain more if needed. Thanks in advance.

    Read the article

  • Codeigniter only loads the default controller

    - by fh47331
    I am very new to CodeIgniter, but have been programming PHP for ages. I'm writing some software at the moment and using CI for the first time with it. The default controller is set to the first controller I want to action call 'login' (the controller is login.php, the view is login.php. When the form is submitted it calls the 'authenticate' controller. This executes fine, process the login data correctly and then does a redirect command (without any output to the screen prior) to the next page in this case 'newspage'. The problem is that the redirect, never reaches 'newspage' but the default controller runs again. It doesn't matter what I put ... ht tp://domain.name/anything ... (yes im using .htaccess to remove the index.php) the anything never gets called, just the default controller. I have left the standard 'welcome.php' controller and 'welcome_message.php' in the folders and even putting ht tp://domain.name/welcome all I get is the login screen! (Obviously there shouldn't be a space between the http - thats just done so it does not show as a hyperlink!) Can anyone tell me what i've done wrong!

    Read the article

  • CodeIgniter: Where should a particular functionality go ?

    - by Samnan
    I have an application in codeigniter and a page needs to perform the following tasks 1 - controller decides which model to use based of the url and parameters 2 - controller loads the model and get the data from it 3 - controller formats the data in a particular format, depending on the items in it 4 - controller loads a common view, which will display the data (formatted data contains simple display fields) now there is a search page, which needs to do a text query against all of the possible text fields in database in all tables. It needs to show each type of data in its own formatted output on a single page as a list. The problem: The search controller can do the search, dynamically load model for each record type, and get the data from model. Problem comes when the data needs to be formatted. It looks that ideally the search controller should load another controller which will provide formatted data ... There is where it gets out of control ... My question is: What am I doing wrong? Is there any better way to do this? How would you do the same to solve the problem?

    Read the article

  • Codeigniter Inputting session data from model for a simple authentication system

    - by user1616244
    Trying to put together a simple login authentication. Been at this for quite sometime, and I can't find where I'm going wrong. Pretty new to Codeigniter and OOP PHP. I know there are authentication libraries out there, but I'm not interested in using those. Model: function login($username, $password){ if ($this->db->table_exists($username)){ $this->db->where('username', $username); $this->db->where('password', $password); $query = $this->db->get($username); if($query->num_rows >= 1) { return true; $data = array( 'username' => $this->input->post('username'), 'login' => true ); $this->session->set_userdata($data); } } } Controller function __construct(){ parent::__construct(); $this->logincheck(); } public function logincheck(){ if ($this->session->userdata('login')){ redirect('/members'); } } If I just echo from the controller: $this-session-all_userdata(); I get an empty array. So the problem seems to be that the $data array in the model isn't being stored in the session.

    Read the article

  • jQuery UI Autocomplete and CodeIgniter

    - by Kere Puki
    I am trying to implement a simple autocomplete script using jQuery UI and CodeIgniter 2 but my model keeps telling me there is an undefined variable so I dont know if my setup is right. My view $(function() { $("#txtUserSuburb").autocomplete({ source: function(request, response){ $.ajax({ url: "autocomplete/suggestions", data: { term: $("#txtUserSuburb").val() }, dataType: "json", type: "POST", success: function(data){ response(data); } }); }, minLength: 2 }); }); My controller function suggestions(){ $this->load->model('autocomplete_model'); $term = $this->input->post('term', TRUE); $rows = $this->autocomplete_model->getAutocomplete($term); echo json_encode($rows); } My Model function getAutocomplete() { $this->db->like('postcode', $term, 'after'); $query = $this->db->get('tbl_postcode'); $keywords = array(); foreach($query->result() as $row){ array_push($keywords, $row->postcode); } return $keywords; } There arent any errors except it doesn't seem to be passing the $term variable to the model.

    Read the article

  • codeigniter populate form from database

    - by Delirium tremens
    In the controller, I have... function update($id = null) { $this->load->database(); // more code $data = array(); $data = $this->db->get_where( 'users', array( 'id' => $id ) ); $data = $data->result_array(); $data = $data[0]; // more code $this->load->view('update', $data); } In the view, I have... <h5>Username</h5> <input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" /> <h5>Email</h5> <input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" /> <h5>Email Confirmation</h5> <input type="text" name="emailconf" value="<?php echo set_value('emailconf'); ?>" size="50" /> <h5>Password</h5> <input type="text" name="password" value="<?php echo set_value('password'); ?>" size="50" /> <h5>Password Confirmation</h5> <input type="text" name="passconf" value="<?php echo set_value('passconf'); ?>" size="50" /> set_value() isn't reading $data search for value="" at http://codeigniter.com/forums/viewthread/103837/ The poster uses only the set_value() function between "" in value="". I'm wondering how to do the same, but I can't get it to work. Help?

    Read the article

  • Formating a date field in the Model (Codeigniter)

    - by Landitus
    Hi, I', trying to re-format a date from a table in Codeigniter. The Controller is for a blog. I was succesfull when the date conversion happens in the View. I was hoping to convert the date in the Model to have things in order. This is the Model: class Novedades_model extends Model { function getAll() { $this->db->order_by('date','desc'); $query = $this->db->get('novedades'); if($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } } return $data; } } This is part of the controller $this->load->model('novedades_model'); $data['records'] = $this->novedades_model->getAll(); Here's the date conversion as it happens in the View. This is inside the posts loop: <?php foreach($records as $row) : ?> <?php $fdate = "%d <abbr>%M</abbr> %Y"; $dateConv = mdate($fdate, mysql_to_unix($row->date)); ?> <div class="article section"> <span class="date"><?php echo $dateConv ;?></span> ... Keeps going ... How can I convert the date in the Model? Can I access the date key and refactor it?

    Read the article

  • mysql to codeigniter active record help

    - by JoeM05
    Active record is a neet concept but sometimes I find it difficult to get more complicated queries to work. I find this is at least one place the CI docs are lacking. Anyway, This is the sql I wrote. It returns the expected results of quests not yet completed by the user that are unlocked and within the users level requirements: SELECT writing_quests . * FROM `writing_quests` LEFT OUTER JOIN members_quests_completed ON members_quests_completed.quest_id = writing_quests.id LEFT OUTER JOIN members ON members.id = $user_id WHERE writing_quests.unlocked =1 AND writing_quests.level_required <= $userlevel AND members_quests_completed.user_id IS NULL This is the codeigniter active record query, it returns all quests that are unlocked and within the users level requirement: $this->db->select('writing_quests.*'); $this->db->from('writing_quests'); $this->db->join('members_quests_completed', 'members_quests_completed.quest_id = writing_quests.id', 'left outer'); $this->db->join('members', "members.id = $user_id", 'left outer'); $this->db->where('writing_quests.unlock', 1); $this->db->where('writing_quests.level_required <=', $userlevel); $this->db->where('members_quests_completed.user_id is null', null, true); I'm guessing there is something wrong with the way I am asking for Nulls. To be thorough, I figured I'd include everything.

    Read the article

  • codeigniter avoiding html div's

    - by rabidmachine9
    Hello there!Is there a proper syntax to avoid div's in codeigniter? I don't really like opening and closing tags all the time... <div class="theForm"> <?php echo form_open('edit/links');//this form uploads echo "Enter the Name: ". form_input('name','name'); echo "Enter the Link: ". form_input('url','url'); echo " ".form_submit('submit', 'Submit'); echo form_close(); if (isset($linksQuery) && count($linksQuery)){ foreach($linksQuery as $link){ echo anchor($link['link'], $link['name'].".", array("class" => "links")); echo form_open('edit/links',array('class' => 'deleteForm')); echo form_hidden('name',$link['name']); echo " ".form_submit('delete','Delete'); echo form_close(); echo br(2); } } ?> </div>

    Read the article

  • Extending the CI_DB_active_record class in codeigniter 2.0

    - by ctrane
    I am writing my first program with Codeigniter, and have run into a problem. I will start with a focused description of the problem and can broaden it if I need to: I need to write a multi-dimensional array to the DB and want to use the insert_batch function from the CI_DB_active_record class to do so. The problem is that I need to write empty values as NULL for some fields while other fields need to be empty strings. The current function wraps all values with single quotes, and I cannot find a way to write null values to the database for specified fields. I would also like to increase the number of records per batch. I see how to extend models, libraries, etc., but is there a way to extend the CI_DB_active_record class without modifying core classes? The minimal amount of core class modification to make this work that I have found is modifying the following lines in the DB.php file (changing the require_once file to the new file that extends the CI_DB_active_record class and changing the CI_DB_active_record class name to the new class name): require_once(BASEPATH.'database/DB_active_rec'.EXT); if ( ! class_exists('CI_DB')) { eval('class CI_DB extends CI_DB_active_record { }'); } Can I do better?

    Read the article

  • Multiple/Sub quries with codeigniter

    - by user1011713
    I just started with Codeigniter and this is driving me nuts. I have a query that determines whether a user has bought any programs. I then have to use that program's type category to run and determine how many times he or she has recorded a query in another table. Sorry for the confusion but the code hopefully makes sense. I'm having problem returning the two arrays from my Model to my Controller to onto the view obviously. function specificPrograms() { $specific_sql = $this->db->query("SELECT program,created FROM `assessment` WHERE uid = $this->uid"); if($specific_sql->num_rows() > 0) { foreach ($specific_sql->result() as $specific) { $data[] = $specific; $this->type = $specific->program; } return $data; } $sub_sql = $this->db->query("SELECT id FROM othertable WHERE user_id_fk = $this->uid and type = '$this->type'"); if($sub_sql->num_rows() > 0) { foreach ($sub_sql->result() as $otherp) { $data[] = $otherp; } return $data; } } Then in my Controller I have, $data['specific'] = $this->user_model->specificPrograms(); $data['otherp'] = $this->user_model->specificPrograms(); Thanks for any help.

    Read the article

  • install codeigniter on apache

    - by pooja
    I already have php and apache installed on my ubuntu 12.04. I want to install codeigniter which is a php framework. I followed the link: How to install CodeIgniter? . But its too complicated and also I do not want to create symlinks and mount and all the stuff mentioned there. Installation instruction are also on the codegniter site i.e. http://ellislab.com/codeigniter/user-guide/installation/index.html , but those are not elaborative and little confusing. I will be very thankful if anyone can please provide a simple way to install codeigniter with apache server.

    Read the article

  • GROUP_CONCAT in CodeIgniter

    - by mickaelb91
    I'm just blocking to how create my group_concat with my sql request in CodeIgniter. All my queries are listed in a table, using Jtable library. All work fine, except when I try to insert GROUP_CONCAT. Here's my model page : function list_all() { $login_id = $this->session->userdata('User_id'); $this->db->select('p.project_id, p.Project, p.Description, p.Status, p.Thumbnail, t.Template'); $this->db->from('assigned_projects_ppeople a'); $this->db->where('people_id', $login_id); $this->db->join('projects p', 'p.project_id = a.project_id'); $this->db->join('project_templates t', 't.template_id = p.template_id'); $this->db->select('GROUP_CONCAT(u.Asset SEPARATOR ",") as assetslist', FALSE); $this->db->from('assigned_assets_pproject b'); $this->db->join('assets u', 'u.asset_id = b.asset_id'); $query = $this->db->get(); $rows = $query->result_array(); //Return result to jTable $jTableResult = array(); $jTableResult['Result'] = "OK"; $jTableResult['Records'] = $rows; return $jTableResult; } My controller page : function listRecord(){ $this->load->model('project_model'); $result = $this->project_model->list_all(); print json_encode($result); } And to finish my view page : <table id="listtable"></table> <script type="text/javascript"> $(document).ready(function () { $('#listtable').jtable({ title: 'Table test', actions: { listAction: '<?php echo base_url().'project/listRecord';?>', createAction: '/GettingStarted/CreatePerson', updateAction: '/GettingStarted/UpdatePerson', deleteAction: '/GettingStarted/DeletePerson' }, fields: { project_id: { key: true, list: false }, Project: { title: 'Project Name' }, Description: { title: 'Description' }, Status: { title: 'Status', width: '20px' }, Thumbnail: { title: 'Thumbnail', display: function (data) { return '<a href="<?php echo base_url('project');?>/' + data.record.project_id + '"><img class="thumbnail" width="50px" height="50px" src="' + data.record.Thumbnail + '" alt="' + data.record.Thumbnail + '" ></a>'; } }, Template: { title: 'Template' }, Asset: { title: 'Assets' }, RecordDate: { title: 'Record date', type: 'date', create: false, edit: false } } }); //Load person list from server $('#listtable').jtable('load'); }); </script> I read lot of posts talking about that, like replace ',' separator by ",", or use OUTER to the join, or group_by('p.project_id') before using get method, don't work. Here is a the output of the query in json : {"Result":"OK","Records":[{"project_id":"1","Project":"Adam & Eve : A Famous Story","Description":"The story about Adam & Eve reviewed in 3D Animation movie !","Status":"wip","Thumbnail":"http:\/\/localhost\/assets\/images\/thumb\/projectAdamAndEve.png","Template":"Animation Movie","assetslist":"Apple, Adam, Eve, Garden of Eden"}]} We can see the GROUP_CONCAT is here (after "assetslist"), but the column stills empty. If asked, I can post the database SQL file. Thank you.

    Read the article

  • Transactions in codeigniter with multiple tables.

    - by Ethan
    Hey SO, I'm new to transactions in general, but especially with CodeIgniter. I'm using InnoDB and everything, but my transactions aren't rolling back when I want them to. Here's my code (slightly simplified). $dog_db = $this->load->database('dog', true); $dog_db->trans_begin(); $dog_id = $this->dogs->insert($new_dog); //Gets primary key of insert if(!$dog_id) { $dog_db->trans_rollback(); throw new Exception('We have had an error trying to add this dog. Please go back and try again.'); } $new_review['dog_id'] = $dog_id; $new_review['user_id'] = $user_id; $new_review['date_added'] = time(); if(!$this->reviews->insert($new_review)) //If the insert fails { $dog_db->trans_rollback(); throw new Exception('We have had an error trying to add this dog. Please go back and try again.'); } //ADD DESCRIPTION $new_description['description'] = $add_dog['description']; $new_description['dog_id'] = $dog_id; $new_description['user_id'] = $user_id; $new_description['date_added'] = time(); if(!$this->descriptions->insert($new_description)) { $dog_db->trans_rollback(); throw new Exception('We have had an error trying to add this dog. Please go back and try again.'); } $booze_db->trans_rollback(); //THIS IS JUST TO SEE IF IT WORKS throw new Exception('We have had an error trying to add this dog. Please go back and try again.'); $booze_db->trans_commit(); } catch(Exception $e) { echo $e->getMessage(); } I'm not getting any error messages, but it's not rolling back either. It should roll back at that final trans_rollback right before the commit. My models are all on the "dog" database, so I think that the transaction would carry into the models' functions. Maybe you just can't use models like this. Any help would be greatly appreciated! Thanks!

    Read the article

  • Codeigniter or PHP Amazon API help

    - by faya
    Hello, I have a problem searching through amazon web servise using PHP in my CodeIgniter. I get InvalidParameter timestamp is not in ISO-8601 format response from the server. But I don't think that timestamp is the problem,because I have tryed to compare with given date format from http://associates-amazon.s3.amazonaws.com/signed-requests/helper/index.html and it seems its fine. Could anyone help? Here is my code: $private_key = 'XXXXXXXXXXXXXXXX'; // Took out real secret key $method = "GET"; $host = "ecs.amazonaws.com"; $uri = "/onca/xml"; $timeStamp = gmdate("Y-m-d\TH:i:s.000\Z"); $timeStamp = str_replace(":", "%3A", $timeStamp); $params["AWSAccesskeyId"] = "XXXXXXXXXXXX"; // Took out real access key $params["ItemPage"] = $item_page; $params["Keywords"] = $keywords; $params["ResponseGroup"] = "Medium2%2525COffers"; $params["SearchIndex"] = "Books"; $params["Operation"] = "ItemSearch"; $params["Service"] = "AWSECommerceService"; $params["Timestamp"] = $timeStamp; $params["Version"] = "2009-03-31"; ksort($params); $canonicalized_query = array(); foreach ($params as $param=>$value) { $param = str_replace("%7E", "~", rawurlencode($param)); $value = str_replace("%7E", "~", rawurlencode($value)); $canonicalized_query[] = $param. "=". $value; } $canonicalized_query = implode("&", $canonicalized_query); $string_to_sign = $method."\n\r".$host."\n\r".$uri."\n\r".$canonicalized_query; $signature = base64_encode(hash_hmac("sha256",$string_to_sign, $private_key, True)); $signature = str_replace("%7E", "~", rawurlencode($signature)); $request = "http://".$host.$uri."?".$canonicalized_query."&Signature=".$signature; $response = @file_get_contents($request); if ($response === False) { return "response fail"; } else { $parsed_xml = simplexml_load_string($response); if ($parsed_xml === False) { return "parse fail"; } else { return $parsed_xml; } } P.S. - Personally I think that something is wrong in the generation of the from the $string_to_sign when hashing it.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >