I
I
Ivan Petrov2017-05-25 12:28:37
MySQL
Ivan Petrov, 2017-05-25 12:28:37

How to make a selection from a database in Yii1?

Hello. There were problems with data sampling using Yii1, I started working a couple of days ago, I can’t figure out how to do it. If through Mysqli, then the query is:

$con = mysqli_connect("localhost","root","","mydental");
mysqli_set_charset($con,"utf8");
$get=mysqli_query($con, "SELECT * FROM city ORDER BY name ASC");

$option = '';
while($row = mysqli_fetch_assoc($get))
{
    $option .= '<option value = "'.$row['name'].'">'.$row['name'].'</option>';
}

How to make it in Yii1? Whether to do connection with a DB and page of selection? Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-05-25
@webinar

offtopic: Why not switch to yii2?
to the point:
here is the documentation, I advise you to study:
www.yiiframework.com/doc/guide/1.1/ru/database.ar
www.yiiframework.com/tour
www.yiiframework.com/doc/api
Your example clearly violates MVC. So I think before you do what you want, you need to go over the guides. Will take a couple of hours.
Here are specific requests: www.yiiframework.com/doc/guide/1.1/ru/database.ar#sec-4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question