Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 1.7.0 Released
#51

[eluser]Armorfist[/eluser]
I had one problem with the database lib too:

Code:
$update_session = $this->db->update('login_sessions',$update_session,'user_id='.$user_id.' AND ip = "'.$ip.'"');

It was returning:

Code:
UPDATE `login_sessions`
SET `timestamp` = 1224889127, `session_id` = '21753c0e5f47d487c82c0127bec5b123', `location` = '/users/admin/admin/index'
WHERE `user_id=1` AND ip = "192.168.0.5"

Notice the `user_id=1`.

To solve this I inserted a space between "user_id", "=" and '.$user_id.':

Code:
$update_session = $this->db->update('login_sessions',$update_session,'user_id = '.$user_id.' AND ip = "'.$ip.'"');

I found it a bit strange and ignored it, but now that more people are having similar problems I decided to post it here to see if it helps.
#52

[eluser]olavski[/eluser]
[quote author="Rick Ellis" date="1224884345"][quote author="DiRN" date="1224880057"][quote author="olavski" date="1224878200"]I just upgraded my app from 1.6.3 to 1.7, and I had some promlems with loading libraries...

It seems that in 1.6.3 you could do this:
$this->load->library("some_lib", "some value");

this does not seem to work in 1.7. Then you'll have to do something like:
$this->load->library("some_lib", array("some value"));

Am I correct in assuming that in v1.7 you can only pass arrays to libraries, not strings etc?[/quote]

CodeIgniter 1.7.0 added this to the library function in Loader.php:
Code:
if ( ! is_null($params) AND ! is_array($params))
{
    $params = NULL;
}

I myself was wondering why this was added. I don't like to make changes to the core CI files, but I'd have to make way too many changes to my controllers to not remove these lines.[/quote]

Per the user guide, the second parameter has always expected an associative array or object, not a string, so that variables can be created. This can't be done with a string, as you seem to be using it.[/quote]


The user guide states "The second parameter allows you to optionally pass configuration setting. You will typically pass these as an array".
To me 'typically' means 'in most cases' and doesn't sound like only arrays are allowed.

With my own libraries I'm happy to conform with whatever is the set standard.
The issues I'm having, are with 3rd party API classes where they sometimes require a string api key as the first variable.
Example:
Code:
$apikey = "12345679ABCDEFGHIJKLMNOPQSTUV";
$obj = new api_class($apikey);
or in CI:
Code:
$this->load->library('api_class', $apikey)
This used to work with 1.6.3 but not now in 1.7.

It wouldn't be a big change to make the 3rd party libraries accept an array instead of a string,
but ideally I would like to leave the 3rd party libraries as they are, so that they can be compatible with any future updates.

Is there a particular reason why you can't pass a string variable(or any type of variable) to a library?

Don't get me wrong, I love codeigniter and v1.7 but just want know what can and can't be done.
#53

[eluser]Boris Strahija[/eluser]
[quote author="DiRN" date="1224902238"]I am now getting errors with
Code:
$this->db->orderby("field1, field2")
as this is producing
Code:
ORDER BY `field1,` field2
[/quote]
I had the same problem. Just do it like this:
Code:
$this->db->orderby("field1");
$this->db->orderby("field2")

Maybe it's a bug, or maybe it's a ew feature Smile
#54

[eluser]jstrebel[/eluser]
Getting failures in active record using table.* in select

Code:
$this->db->select('table1.*,table2.field,table2.field);

Seems you have to use the second param "false" now to not throw an error.

Code:
$this->db->select('table1.*,table2.field,table2.field,false);
#55

[eluser]orotone[/eluser]
You might want to look at this thread for the problems with using the splat in SELECT statements:
Thread on using .* in 1.7.0
Edit: fix URL as noted below
#56

[eluser]JayTee[/eluser]
With the new Form Validation class, I like how much less verbose it is when I'm checking for errors on a specific field:

1.6.3 style:
Code:
<div class="required&lt;?= $this->validation->field_error ? ' error':'' ?&gt;">

1.7.0 style:
Code:
<div class="required&lt;?= form_error('username') ? ' error':''?&gt;">

I haven't tested this (yet) - just glad it's less typing for large forms! Smile
#57

[eluser]Jon L[/eluser]
[quote author="orotone" date="1224915041"]You might want to look at this thread for the problems with using the splat in SELECT statements:
Thread on using .* in 1.7.0[/quote]

your URL is broken.

Corrected url: Thread on using .* in 1.7.0
#58

[eluser]Crimp[/eluser]
More examples of AR 1.7 errors:

Code:
, DATE_FORMAT(field, `'%d`.`%m`.`%Y')` AS field,

1.6.3 worked OK with this function. Second parameter in select not set to FALSE, of course.
#59

[eluser]pistolPete[/eluser]
I also dislike the need to pass the initialisation parameter as an array.

For example I am using a Layout library and I am passing the layout's view to the constructor.
Code:
function Layout($layout = "frontend/layout")
    {
        $this->obj =& get_instance();
        $this->layout = $layout;
    }

Why should I pass an array when I just need one parameter and want to have a default value?
#60

[eluser]stuffradio[/eluser]
Great release! Haven't played with it yet, but I'm counting down the days till CI 2.0 with the hopefully native Ajax support Wink




Theme © iAndrew 2016 - Forum software by © MyBB