Welcome Guest, Not a member yet? Register   Sign In
Not connecting to DB
#5

(07-11-2023, 01:17 PM)cbd Wrote: Is it possible to test database connection outside XAMPP ?
Yes, it is possilbe if you configure correctly.

(07-11-2023, 01:17 PM)cbd Wrote: I have this error, but the credentials are correct :

Main connection [MySQLi]: Access denied for user '****'@localhost (using password: YES)

Is this code of the Model correct ?
Shouldn't I have something like $this->db = \Config\Database::connect() in the constructor ?

No, you don't.

(07-11-2023, 01:17 PM)cbd Wrote:
PHP Code:
class NewsModel extends Model
{
    protected $table 'news';

    public function getNews($slug false)
    {
        if ($slug === false) {
            return $this->findAll();
        }

        return $this->where(['slug' => $slug])->first();
    }

Reply


Messages In This Thread
Not connecting to DB - by cbd - 07-10-2023, 02:19 PM
RE: Not connecting to DB - by kenjis - 07-10-2023, 03:55 PM
RE: Not connecting to DB - by cbd - 07-11-2023, 01:17 PM
RE: Not connecting to DB - by kenjis - 07-11-2023, 07:29 PM
RE: Not connecting to DB - by JustJohnQ - 07-11-2023, 07:17 PM
RE: Not connecting to DB - by InsiteFX - 07-11-2023, 10:51 PM
RE: Not connecting to DB - by cbd - 07-13-2023, 07:36 AM
RE: Not connecting to DB - by cbd - 07-13-2023, 09:00 AM
RE: Not connecting to DB - by InsiteFX - 07-13-2023, 11:10 PM
RE: Not connecting to DB - by cbd - 07-21-2023, 12:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB