Reputation: 888
I have two classes. UserModel and UserController.
file: localhost/controllers/user.controller.php
<?php
class UserController
{
public function GetArray() {
$query = 'SELECT id, username, email, password FROM Users';
$result = mysql_query($query);
$model = new UserModel();
while ($row = mysql_fetch_array($result)) {
$model->id = $row['id'];
$model->username = $row['username'];
$model->email = $row['email'];
$model->password = $row['password'];
$array[] = $model;
}
return $array;
}
}
?>
The UserModel class is in another file: localhost/models/user.model.php. The 6th row is causing the error, because there's no references to the other file. How can I do that?
Sorry for my bad english, and thanks to you all.
Upvotes: 0
Views: 361
Reputation: 1287
See the following link. Use any of th method to call a class inside another class. Thanks
Calling a class inside another one in PHP
Upvotes: 0
Reputation: 91902
Use require or require_once to include the other file.
Upvotes: 2