Welcome Guest, Not a member yet? Register   Sign In
Trying to call uasort from within a model method
#1

[eluser]blcArmadillo[/eluser]
I'm trying to call a custom sort function from within a method in one of my models so I have something like:

Code:
<?php
class Part_model extends Model {
    
    function __construct()
    {
        parent::Model();
    }

    function my_sort($a, $b)
    {
        // sort code
    }

    function some_method()
    {
        $anarray = array(...);
        uasort($parts, 'my_sort');
    }

Problem is I get the following error:
Quote:uasort() expects parameter 2 to be a valid callback, function 'my_sort' not found or invalid function name.

I'd imagine this is because just like if you were calling the function normally from the method you'd use something like $this->my_sort('aval', 'bval'). I tried passing '$this->my_sort' into the second argument but that didn't work either. Any ideas?


Messages In This Thread
Trying to call uasort from within a model method - by El Forum - 06-09-2010, 06:30 AM
Trying to call uasort from within a model method - by El Forum - 06-09-2010, 06:37 AM
Trying to call uasort from within a model method - by El Forum - 06-09-2010, 06:42 AM
Trying to call uasort from within a model method - by El Forum - 06-09-2010, 06:50 AM
Trying to call uasort from within a model method - by El Forum - 06-09-2010, 07:21 AM
Trying to call uasort from within a model method - by El Forum - 06-09-2010, 09:02 AM
Trying to call uasort from within a model method - by El Forum - 06-09-2010, 09:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB