Wrox Programmer Forums
|
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 7th, 2009, 08:15 AM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Wrox CodeIgniter Professional 2008

Hi. I was contemplating purchasing a copy of "Wrox CodeIgniter Professional 2008", and I was having a look at the free sample chapter. The are two places on the page where $q->free_result() is called after the return statement.

PHP Code:
<?php
class Page_model extends Model{
    function 
Page_model(){
        
parent::Model();
    }
    function 
fetchHomePage(){
        
$data = array();
        
$options = array(‘status’ => â€˜live’‘type’=> â€˜home’);
        
$q $this->db->getwhere(‘pages’$options1);
        if (
$q->num_rows() > 0){
            
$data $q->row_array();
        }
        return 
$data;
        
$q->free_result();
    }
}
?>
and

PHP Code:
<?php
class Page_model extends Model{

    function 
Page_model(){
        
parent::Model();
    }
    
    function 
fetchHomePage(){
        
$data = array();
        
$options = array(‘status’ => â€˜live’‘type’=> â€˜home’);
        
$q $this->db->getwhere(‘pages’$options1);
        if (
$q->num_rows() > 0){
            
$row $q->row();
            
$data[‘title’] = $row->title;
            
$data[‘css’] = $row->css;
            
$data[‘keywords’] = $row->keywords;
            
$data[‘description’] = $row->description;
            
$data[‘bodycopy’] = nl2br($row->bodycopy);
        }
        return 
$data;
        
$q->free_result();
    }
}
?>
This could be a simple mistake, but it's repeated twice on the page and should have been picked up on during proof-reading. Here's what PHP says about the return statement:

Quote:
If called from within a function, the return() statement immediately ends execution of the current function, and returns its argument as the value of the function call.
So basically, $q->free_result() will never be reached as it appears immediately after the return statement.

Would anybody recommend the book? I'm still interested in purchasing it, but I have my doubts as to how accurate the rest of the information may be.

Thanks in advance.
 
Old March 7th, 2009, 10:15 AM
jminatel's Avatar
Wrox Staff
Points: 18,059, Level: 58
Points: 18,059, Level: 58 Points: 18,059, Level: 58 Points: 18,059, Level: 58
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
Default

Hi thefuzzy0ne: I've moved your post here to the book forum in hope that the author will see it. He's been active answering questions, although not lately. I'll ping him to be sure we didn't lose him when we launched the new forums.
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click on their post!
 
Old March 7th, 2009, 10:18 AM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, Jim!
 
Old March 16th, 2009, 09:57 AM
Wrox Author
 
Join Date: May 2008
Posts: 53
Thanks: 0
Thanked 5 Times in 5 Posts
Default simple proofreading error

Hi there,

I think what you're seeing is a simple proof-reading error. About three quarters through the book, the reviewer and I decided on a huge number of changes, then went through a large cleanup process. It looks like we missed a few obvious things.

You are, of course, 100% correct -- the return line will end the method/function and the free_result will never occur....although, from what I understand, CI will free the result anyway. It's just good practice to do it manually.
__________________
Thomas Myer
Author, Professional CodeIgniter
http://www.tripledogs.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL 2008 will not run on Windows 2008? dkrus Book: Professional Microsoft SQL Server 2008 Administration ISBN: 978-0-470-24796-9 1 February 23rd, 2009 12:34 PM
VB 2008 Wrox Articles jminatel Visual Basic 2008 Professionals 0 February 8th, 2008 09:09 PM
servlet example-Wrox Professional JAVA XML sarahmapg Servlets 1 August 5th, 2004 12:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.