Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Active Record - baza

[es] :: PHP :: PHP za početnike :: Active Record - baza

[ Pregleda: 1215 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

termofarm.ex
Beograd

Član broj: 313949
Poruke: 2
*.dynamic.mbb.telenor.rs.



+2 Profil

icon Active Record - baza29.07.2015. u 15:14 - pre 54 meseci
Pozdrav svima,

Imam problem sa ActiveRecordom u pitanju je konekcija, koristim source code php-activerecord-1.0.zip, a kod koji radim je sledeći:

db.php

<?php

require_once 'activerecord/ActiveRecord.php';
//require_once dirname(__FILE__) . 'config.php';

class UserSQL extends ActiveRecord\Model
{
static $table = "users";
public static function insert_user($username,$password,$first_name,$last_name)
{
if(username != null && password != null && first_name != null && last_name != null)
{
if(!self::find_by_username($username))
{
$user = new UserSQL;
$user->username = $username;
$user->password = $password;
$user->first_name = $first_name;
$user->last_name = $last_name;
$user->save();
echo "Korisnik unesen";
}else echo "Korisnik postoji";
}else{
echo "Not saved";
}
}

}

ActiveRecord\Config::initialize(function($cfg)
{
$cfg->set_model_directory('.'); //ili class ako stavljam klase u class file ili models ako fajl za klase nazovem tako
$cfg->set_connections(array(
'development' => 'mysql://localhost/photo_gallery'));
});

?>


index.php

<?php

require_once "../includes/db.php";

$user = New UserSQL;
$user->username = "Marko";
$user->password = "hddjash";
$user->first_name = "Marko";
$user->last_name = "Stanić";
$user->save();

echo "Radi li ovo?";

?>


OVO JE GRESKA

Fatal error: in C:\wamp\www\photo_gallery\includes\activerecord\lib\Connection.php on line 241
( ! ) ActiveRecord\DatabaseException: in C:\wamp\www\photo_gallery\includes\activerecord\lib\Connection.php on line 241
Call Stack
# Time Memory Function Location
1 0.0010 133880 {main}( ) ..\index.php:0
2 0.0250 852856 ActiveRecord\Model->__construct( ) ..\index.php:5
3 0.0250 853024 ActiveRecord\Model::table( ) ..\Model.php:257
4 0.0250 853128 ActiveRecord\Table::load( ) ..\Model.php:744
5 0.0250 853800 ActiveRecord\Table->__construct( ) ..\Table.php:61
6 0.0250 854480 ActiveRecord\Table->reestablish_connection( ) ..\Table.php:80
7 0.0250 854592 ActiveRecord\ConnectionManager::get_connection( ) ..\Table.php:103
8 0.0250 854840 ActiveRecord\Connection::instance( ) ..\ConnectionManager.php:33
9 0.0290 881360 ActiveRecord\Connection->__construct( ) ..\Connection.php:101
 
Odgovor na temu

[es] :: PHP :: PHP za početnike :: Active Record - baza

[ Pregleda: 1215 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.