j4mie / paris

A lightweight Active Record implementation for PHP5, built on top of Idiorm.
http://j4mie.github.com/idiormandparis/
996 stars 131 forks source link

Installed idiorm and paris, but paris.php gives me a HTTP 500 error. #57

Closed soodarvind closed 11 years ago

soodarvind commented 11 years ago

I installed as per your instructions, and while idiorm.php returns HTTP 200 OK, Paris.php bungs an error every time I try to test with it.

soodarvind commented 11 years ago

<?php require_once 'lou.class.php'; require_once './vendor/j4mie/idiorm/idiorm.php'; require_once './vendor/j4mie/paris.paris.php'; ORM::configure('mysql:host=localhost;dbname=lou'); ORM::configure('username', 'admin'); ORM::configure('password', 'password'); .... then db functions

?>

When I run my php, it also responds with a HTTP 200 message, but no data populates.

When i try to run idiorm.php direct, it responds ok HTTP 200.

When I try to run paris.php direct, it gives me a HTTP 500 error.

I am trying to run the demo php's provided, but again, after configuring the ORM as per instructions there, I get http 200 errors.

What am I doing wrong?

treffynnon commented 11 years ago
  1. You cannot test Idiorm and Paris by accesing their files directly through a web browser.
  2. Paris depends upon Idiorm so that is probably why you're getting an error accessing it's file directly.
  3. Your line requiring Paris into your project has a dot/period (.) where there should be a slash (/).
  4. You need to turn on display_errors and set error_reporting to it's highest level to debug PHP. You cannot debug via HTTP response headers from the web server.
  5. You should install xdebug to help you debug your project more easily.
  6. How are we meant to help you further if you leave out all your DB functions?
  7. For more information please see the documentation rather than the demo.php file.
soodarvind commented 11 years ago

Here's all my source, masking my authentication data.

My relative path actually requires the dot/period. Running in xdebug without, it fails to find the file(s) paris.php or idiorm.php - which have been installed into the relative subdirectories.

am trying to use xdebug but it isn't showing me any errors.

<!DOCTYPE html> <?php

require_once 'lou.class.php'; 
require_once './vendor/j4mie/idiorm/idiorm.php';
require_once './vendor/j4mie/paris/paris.php';

ORM::configure('mysql:host=localhost;dbname=lou');
ORM::configure('username', 'admin');
ORM::configure('password', 'password');

Class Player extends Model{}
Class PlayerScore extends Model{}

$lou = LoU::createClient( './cookies/' );
$lou->login( 'xyz@xyz.com', 'abcd' )->selectWorld( 232 );

function getRankList( $type )
{
    global $lou;

    $type = ucfirst( strtolower( $type ) );
    $count = $lou->get( $type . 'GetCount', array( "continent" => -1,"sort" => 0,"ascending" => true,"type" => 0 ) );

    $iter = intval( $count / 400 );
    $left = intval( $count % 400 );
    $start = 0;
    $end = 399;
    $send = array();

    for ($x = 0; $x < $iter; $x++)
    {
        $send[] = array( 'start' => $start, 'end' => $end );
        $start += 400;
        $end += 400;
    }
    if( $left > 0 )
    {
        $send[] = array( 'start' => ( $count - $left ), 'end' => ( $count - 1 ) );
    }

    $data = array();
    foreach( $send as $s )
    {
        $s = array_merge( $s, array( "continent" => -1,"sort" => 0,"ascending" => true,"type" => 0 ) );
        $res = $lou->get( $type . 'GetRange', $s );
        $data = array_merge( $data, $res );
    }

    return $data;
}
$alliance_name = 'Scrubber Duckies';
$alliance_id = 0;

// Our function at work!
$alliance_list = getRankList( 'alliance' );
foreach( $alliance_list as $alliance )
{
    if( strtolower( $alliance_name ) == strtolower( $alliance->n ) )
    {
        $alliance_id = $alliance->i;
    }
}
$members = $lou->get( 'GetPublicAllianceMemberList', array( 'id' => $alliance_id ) );
foreach( $members as $member )
{
    // Store player info
    $player_db = Model::factory( 'Player' )->find_one( $member->i );
    // Record not found, create it
    if( !$player_db instanceof Player )
    {
        $player_db = Model::factory( 'Player' )->create();
        $player_db->id = $member->i;
        $player_db->alliance_id = $alliance_id;
        $player_db->name = $member->n;
    }
    $player_db->updatedAt = date( 'Y-m-d H:i:s' );
    $player_db->save();

    // Store player score
    $player_score_db = Model::factory( 'PlayerScore' )->where( 'player_id', $member->i )->where( 'day', date( 'Y-m-d' ) )->find_one();
    // Record not found create a new entry
    if( !$player_score_db instanceof PlayerScore )
    {
        $player_score_db = Model::factory( 'PlayerScore' )->create();
        $player_score_db->player_id = $member->i;
        $player_score_db->day = date( 'Y-m-d' );
    }
    $player_score_db->alliance_id = $alliance_id;
    $player_score_db->score = $member->p;
    $player_score_db->rank = $member->r;
    $player_score_db->city_count = $member->c;
    $player_score_db->updatedAt = date( 'Y-m-d H:i:s' );
    $player_score_db->save();}

?>

treffynnon commented 11 years ago

What are your table names in the database?

soodarvind commented 11 years ago

player and player_score.

i am going to go back and exclude all other codes and make sure the basic paris and idiorm modules work on my environment, then go from there.

treffynnon commented 11 years ago

I have not had a chance to read your code. I am not sure why your installation is not throwing any errors. Is it writing to an error log rather than displaying errors?

treffynnon commented 11 years ago

Have you made any progress on this issue? Anything further I can do to help?