Welcome Guest, Not a member yet? Register   Sign In
Code Igniter Book
#11

[eluser]t'mo[/eluser]
[quote author="David U" date="1205711559"]You're right, the link has disappeared. I've asked packt to put it back.

What in particular about unit testing is holding you up?[/quote]

I'm trying to test is a scenario where the DB throws back an error/exception - e.g., trying to write code that will catch a "duplicate key" error and handle it gracefully. In Java (day job), for example, I can wrap my assertions in "try...catch" blocks, ensure that the equivalent of my Model class is doing the right thing, and thus write the code that uses the Model appropriately.

I'm attempting to do the same with "set_error_handler", but it's not working. I was hoping that the book would have some suggestions, especially since it was mentioned there's an entire chapter dedicated to unit testing.

(Of course, PHP is not Java, and given my newness at PHP, I might be approaching the problem from entirely the wrong angle. But for personal projects on my own time, I'm really enjoying the light-weightness of the PHP/CI/MySQL stack - who wants the heaviness of Java/Struts/Oracle at home? Ick!)
#12

[eluser]Developer13[/eluser]
Here's a link to my review on Amazon if you're interested: http://www.amazon.com/review/R12DNMABO4U...r_rdp_perm
#13

[eluser]David U[/eluser]
As regards the CodeIgniter book, Packt say the link to download the book is
http://www.packtpub.com/codeigniter-php-...t-mvc/book

This is working at the moment.

As regards t'mo's query, I'm not aware of an easy way to stop unsightly MySQL error messages appearing on the screen. If I have a query that I think may not work in a production environment, I either call it first using

Code:
$this->db->simple_query();

which doesn't answer the query but just returns TRUE or FALSE depending on whether it is valid. If it is FALSE then I don't go on to do the query properly.


Or else you can wrap it in an 'if' statement

Code:
if(!$this->db->query('my_query'));
    {
    exception code here...
    }
else { carry on...}

For a select query I think it will also work to say

Code:
if(!$query = $this->db->query('my_query'));
    {
    exception code here...
    }

One point I was trying to make in the book though is that it is important to be clear, when writing tests on code that involves DB queries, what you mean by a FALSE or 0 answer.

FALSE may actually be correct, eg a unit test might give the same response for a badly constructed query that fails at the DB level, as it would for a correctly-formed query that gives a NULL return because no data meets those conditions. The unit test needs to take this into account. One way is to put some dummy data in your table and then look for it, so you know what to expect, and then remove the dummy data afterwards.
#14

[eluser]Frank Rocco[/eluser]
Hello,

Does the book get into authorization/roles and database pagination?

Thanks

Frank
#15

[eluser]louis w[/eluser]
I thought it was pretty good. I got it when I had not known anything about CI except for the fact that I wanted to use it. The book was a easy quick way to get to know all the features.

My only complaint was that I did not like how so much of the book was focused on making a bug tracker. I felt a more generic example would have been better. He spent a lot of time going into the details of making a bug tracker which I did not really need to know.
#16

[eluser]kgill[/eluser]
[quote author="vadivel" date="1205711524"]hi ccachor

im get one ebook, i think that more useful for u
take that link
[/quote]

Seriously not cool there, posting a link to a pirated copy right below a post by the author...
#17

[eluser]louis w[/eluser]
[quote author="kgill" date="1205805698"][quote author="vadivel" date="1205711524"]hi ccachor

im get one ebook, i think that more useful for u
take that link
[/quote]

Seriously not cool there, posting a link to a pirated copy right below a post by the author...[/quote]

No kidding. It's not that expensive, buy it.
#18

[eluser]Derek Allard[/eluser]
The link's been removed. I'm sure you were trying to be helpful, so thanks, but we'd all prefer the official link get used.
#19

[eluser]David U[/eluser]
In answer to part of Frank Rocco's query - on roles and authorisation you can't in my opinion do better than use Freakauth (http://www.4webby.com/freakauth/) which is a very flexible package that allows you to do most things you might need. It's mentioned in the book but only briefly: however it has quite a lot of documentation on its site.
#20

[eluser]Frank Rocco[/eluser]
Thanks Dave,

I was just about to ask which authorizaion library most use.

Two big issues for me in CI are:
Paging & Security/Roles

I looked at cake, but too many calories.<g>

Zend Framework looks interesting, wonder how it would work in CI.

Regards,

Frank




Theme © iAndrew 2016 - Forum software by © MyBB