Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • I think I will lose some performance, but basically, it is like self::prepare('SELECT * FROM ' . self::getPrefix([$dbname if multiple DB, or null for current DB]) . 'usuarios WHERE usuario = :username LIMIT 1');.. (static member could be $this->getPrefix(), or $db->getPrefix(), etc) Commented Apr 19, 2012 at 20:45
  • I just used the normal PDO, PDOStatement code, but if you see what I'm saying you can just alter the code to work with your database abstraction layer. Commented Apr 19, 2012 at 20:49
  • Yes yes, I'm talking: with this way, I need to have a method/function to insert the prefix. For this, I can store the prefix in config.php and get with $db->getPrefix() for instance, which is the easiest way.. With this approach, what about self::prepare('SELECT * FROM #__usuarios WHERE usuario = :username LIMIT 1');, and inside my Model prepare() replace #__ to config.php defined table prefix. Commented Apr 19, 2012 at 20:57
  • 1
    it would be easier to inclue the file that defines the prefix require_once('table_settings.php');, define the prefix as global in the function so that you have access to it getUser { global $prefix; ... }, then do it like this: self::prepare('SELECT * FROM '.$prefix.'usuarios WHERE usuario = :username'); but I think whichever way will work. Commented Apr 19, 2012 at 21:02
  • Thanks for your help, it helped me to think this way. =) Commented Apr 19, 2012 at 21:21