Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

table specified does not exist in the database

posted by cecil chua 8 years ago

I've got another problem. With fDatabase, I can connect to the table "patient" just fine. fORM tells me the table "patient" doesn't exist. I've tried "dbo.Patient" in fORM with the same result. I note in the error message that fORM seems to be able to figure out that PatientID is the name of the primary key.

This is the output

AbelBethCharlieDanielElizabethFionaGeorgeHarryIgnatiusJacobKarenLeslieMarionNickOscarPeterQureshiRomeoSallyTerenceUlyssesVictorWilliamXavierYosemiteZaharaAliceBeatriceCallyDowhop Fatal error: Uncaught exception 'fProgrammerException' with message 'The table specified, patient, does not exist in the database' in E:\\Websites\\INFOSYS280\\flourish\\fSchema.php:2329
Stack trace:
#0 E:\\Websites\\INFOSYS280\\flourish\\fORMDatabase.php(1144): fSchema->getColumnInfo('patient', 'PatientID', 'placeholder')
#1 E:\\Websites\\INFOSYS280\\flourish\\fORMDatabase.php(482): fORMDatabase::makeCondition(Object(fSchema), 'Patient', 'PatientID', '=', 'p01')
#2 E:\\Websites\\INFOSYS280\\flourish\\fActiveRecord.php(1869): fORMDatabase::addPrimaryKeyWhereParams(Object(fSchema), Array, 'Patient', 'Patient', Array, Array)
#3 E:\\Websites\\INFOSYS280\\flourish\\fActiveRecord.php(1168): fActiveRecord->load()
#4 E:\\Websites\\INFOSYS280\\LabWork\\aehchua\\testflourish.php(26): fActiveRecord->__construct('p01')
#5 {main} thrown in E:\\Websites\\INFOSYS280\\flourish\\fSchema.php on line 2329 

This is the code


<?php 
ini_set("error_reporting",E_ALL);
ini_set("display_errors",1);

include_once $_SERVER['DOCUMENT_ROOT'] . "/flourish/toinclude.php";
class Patient extends fActiveRecord
{
  protected function configure()
   {
   }
}


$connstr="ISOMTEACHING5\\INFOSYS280";
$conninfo=array("Database"=>"hospitalSQL");

$testdb=new fDatabase("mssql", "hospitalSQL","mytest","",$connstr,61495);
$result=$testdb->query("Select PatientName from Patient");
foreach ($result as $row)
  echo $row["PatientName"];

//echo "It is working"; 

fORMDatabase::attach(new fDatabase("mssql", "hospitalSQL","mytest","",$connstr,61495));
fORM::mapClassToTable("Patient","Patient");
$mypatient = new Patient("p01");
echo $mypatient->PatientName;

?>}}}


Just a note this is happening with every database I try. I've tried with three databases on the same server, and I get an error message that the table in the database is not found.

posted by cecil chua 8 years ago

From a casual glance, this appears to be because the table names are not all lower case. In a new version of fSchema that should come out in the next day or two I can include a fix for this. Alternatively you can try editing the ->getTables() method in fSchema to add strtolower() around the lines assigning values to $this->tables[].

posted by wbond 8 years ago

What I did was change all the table names to lowercase in the database.

Another bug. It seems to have problems converting ntext. I would have thought ntext would be converted to a string rather than a blob (like it seems to be trying to do). I changed my ntext to nvarchar(50) and it worked fine.

So far, the short segment of code seems to be working.

posted by cecil chua 8 years ago