Welcome Guest, Not a member yet? Register   Sign In
Working with database
#1

(This post was last modified: 07-22-2020, 04:25 AM by jreklund.)

Hello everyone,

I am new to Codeigniter framework.

The first thing I notice is that the documentation is giving me problem. it is not self-explanatory enough. Some php snipets are shown and the files in which the codes will be effected are not specified. This is taking some of my time before I get things right.

My main question is, Does Codeigniter have its own in-built database or it can be used with a database created phpmyadmin.

I am on the news section on tutorial page of code igniter3 documentation. I have problem with this.

Before querying the database, a database schema has to be created. Connect to your database and run the SQL command below (MySQL). Also add some seed records.

Code:
CREATE TABLE news (
        id int(11) NOT NULL AUTO_INCREMENT,
        title varchar(128) NOT NULL,
        slug varchar(128) NOT NULL,
        text text NOT NULL,
        PRIMARY KEY (id),
        KEY slug (slug)
);

How do I run the sql script and ensure that the table news  is created.
Reply
#2

This is what the error page displays after I finish running  index.php/news


An uncaught Exception was encountered
Type: ParseError
Message: syntax error, unexpected 'TABLE' (T_STRING)
Filename: C:\xampp\htdocs\ci\application\models\News_model.php
Line Number: 17
Backtrace:
File: C:\xampp\htdocs\ci\application\controllers\News.php
Line: 7
Function: model
File: C:\xampp\htdocs\ci\index.php
Line: 315
Function: require_once
Reply
#3

You need to connect to your SQL server in some way, either with phpmyadmin if you want a gui or execute it with "mysql", command line client.
Reply
#4

(07-22-2020, 04:27 AM)jreklund Wrote: You need to connect to your SQL server in some way, either with phpmyadmin if you want a gui or execute it with "mysql", command line client.
Thanks so much for the urgent reply. Heart Big Grin

How do I connect to MySql database using phpmyadmin.

How do I run the script from codeigniter to ensure that codeigniter can access the database.

Am sorry oo, if I disturb. I am a newbie just trying to use codeigniter.
Reply
#5

No worries mate, we all started out as beginners.

(07-22-2020, 05:06 AM)rahmanwebdeveloper Wrote: How do I connect to MySql database using phpmyadmin.

You probably already have it installed, it comes with xampp.
https://skillforge.com/how-to-create-a-d...min-xampp/

(07-22-2020, 05:06 AM)rahmanwebdeveloper Wrote: How do I run the script from codeigniter to ensure that codeigniter can access the database.

It's referenced in the tutorial - Setting up your model.
"Make sure you’ve configured your database properly as described here."
Reply
#6

(07-22-2020, 06:07 AM)jreklund Wrote: No worries mate, we all started out as beginners.

(07-22-2020, 05:06 AM)rahmanwebdeveloper Wrote: How do I connect to MySql database using phpmyadmin.

You probably already have it installed, it comes with xampp.
https://skillforge.com/how-to-create-a-d...min-xampp/
 
Sorry , that's not what I meant. I mean , How can i connect code igniter application to the database I created in phpmyadmin.

I will go through the links you shared with me.

Thanks.
Reply
#7

(This post was last modified: 07-22-2020, 07:21 AM by rahmanwebdeveloper.)

(07-22-2020, 06:07 AM)jreklund Wrote: No worries mate, we all started out as beginners.

(07-22-2020, 05:06 AM)rahmanwebdeveloper Wrote: How do I connect to MySql database using phpmyadmin.

You probably already have it installed, it comes with xampp.
https://skillforge.com/how-to-create-a-d...min-xampp/

(07-22-2020, 05:06 AM)rahmanwebdeveloper Wrote: How do I run the script from codeigniter to ensure that codeigniter can access the database.

It's referenced in the tutorial - Setting up your model.
"Make sure you’ve configured your database properly as described here."

Another question please, when editing database.php in config folder, Is it only the database_name I will edit? Can i leave 'dbdriver' => 'mysqli', intact as it is. I hope my connection to the database will still work fine?

I am having great determination in knowing codeigniter because I know it is a good framework to develop web application.

(07-22-2020, 06:30 AM)rahmanwebdeveloper Wrote:
(07-22-2020, 06:07 AM)jreklund Wrote: No worries mate, we all started out as beginners.

(07-22-2020, 05:06 AM)rahmanwebdeveloper Wrote: How do I connect to MySql database using phpmyadmin.

You probably already have it installed, it comes with xampp.
https://skillforge.com/how-to-create-a-d...min-xampp/

(07-22-2020, 05:06 AM)rahmanwebdeveloper Wrote: How do I run the script from codeigniter to ensure that codeigniter can access the database.

It's referenced in the tutorial - Setting up your model.
"Make sure you’ve configured your database properly as described here."

Another question please, when editing database.php in config folder, Is it only the database_name I will edit? Can i leave 'dbdriver' => 'mysqli', intact as it is. I hope my connection to the database will still work fine?

I am having great determination in knowing codeigniter because I know it is a good framework to develop web application.


Thanks so much @jreklund, it has worked fine now. I now understand how codeigniter works.
Thanks a lot.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB