TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-01-2009, 05:19 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default Getting irritated

So, I'm really getting irritated by this error. It worked GREAT before when I used it in my MVC framework, but when I extracted the DB class from the framework(edited some path's and stuff), it just won't work.

PHP Code:
public function __call($function$params)
    {
        
        
var_dump($params);
        
$args split(', '$params[0]);
        return 
call_user_func_array(array($this->DB_Helper$function), $args);
        
    } 
Gives me this:

Code:
array(1) { [0]=>  string(7) "user_id" } array(0) { }
Notice: Undefined offset: 0 in D:\Wamp\www\Lemons_Ny\includes\classes\MySQL_Driver.php on line 244
244 => $args = split(', ', $params[0]);

I'm calling it like this:
PHP Code:
$data['sql'] = $user->user_check('testname''pass'); 
and user_check where I'm using the __call method:
PHP Code:
public function user_check($user_name$user_pass
        {
            
            
$this->db->select('user_id')->table('users')->where('user_name'$user_name)->where('user_pass'$user_pass);                
            
$query $this->db->get();
            
            return 
$query;
            
        } 
Any ideas?? Tell me if you need more codesnippets.
__________________
Tanax is offline  
Reply With Quote
Old 08-01-2009, 05:30 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Does $this->db->get() also get routed through that __call method?
Salathe is offline  
Reply With Quote
Old 08-01-2009, 10:12 PM   #3 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Yes, it does.
__________________
Tanax is offline  
Reply With Quote
Old 08-03-2009, 01:41 PM   #4 (permalink)
The Wanderer
 
JaimePinheiro's Avatar
 
Join Date: Jul 2009
Posts: 5
Thanks: 0
JaimePinheiro is on a distinguished road
Default

are you sure about splitting zero index of $params? $params is an array, isnīt it?
JaimePinheiro is offline  
Reply With Quote
Old 08-08-2009, 08:47 PM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Quote:
Originally Posted by JaimePinheiro View Post
are you sure about splitting zero index of $params? $params is an array, isnīt it?
It worked before I reorganized the directory structure.
__________________
Tanax is offline  
Reply With Quote
Old 08-12-2009, 09:00 AM   #6 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Solved it.
PHP Code:
public function __call($function$params null)
    {
        
        
$args = ($params == null) ? '' split(', '$params[0]);
        if(
is_object($this->DB_Helper))
        {
            
            if(
$args != '')
            {
            
                return 
call_user_func_array(array($this->DB_Helper$function), $args);
                
            }
            
            return 
call_user_func(array($this->DB_Helper$function));
            
        }
        
        die(
'DB_Helper is not loaded. Check out database config file.');
        return 
false;
        
    } 
__________________
Tanax is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:01 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design