Problem with inserting data into database...

thread: 4 messages  |  last: about 2 years ago  |  started: monday, september 7, 2009, 11:09 pm pdt


#1  |  Eestlane Estonia
Monday, September 7, 2009, 11:09 PM PDT

demo.php (same as in tutorial) gives:

Fatal error: Call to undefined method Person::queryhelper() in C:\www\vhosts\localhost\includes\data_classes\generated\PersonGen.class.php on line 551

<?php

    
require('includes/prepend.inc.php');    

    
$objPerson = new Person();
    
$objPerson->FirstName 'Mike';
    
$objPerson->Save();

?>
Done.

Person.class.php:

<?php
    
require(__DATAGEN_CLASSES__ '/PersonGen.class.php');

    
/**
     * The Person class defined here contains any
     * customized code for the Person class in the
     * Object Relational Model.  It represents the "person" table 
     * in the database, and extends from the code generated abstract PersonGen
     * class, which contains all the basic CRUD-type functionality as well as
     * basic methods to handle relationships and index-based loading.
     * 
     * @package My Application
     * @subpackage DataObjects
     * 
     */
    
class Person extends PersonGen {
        
/**
         * Default "to string" handler
         * Allows pages to _p()/echo()/print() this object, and to define the default
         * way this object would be outputted.
         *
         * Can also be called directly via $objPerson->__toString().
         *
         * @return string a nicely formatted string representation of this object
         */
        
public function __toString() {
            return 
sprintf('Person Object %s',  $this->intId);
        }



        
// Override or Create New Load/Count methods
        // (For obvious reasons, these methods are commented out...
        // but feel free to use these as a starting point)
/*
        public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses = null) {
            // This will return an array of Person objects
            return Person::QueryArray(
                QQ::AndCondition(
                    QQ::Equal(QQN::Person()->Param1, $strParam1),
                    QQ::GreaterThan(QQN::Person()->Param2, $intParam2)
                ),
                $objOptionalClauses
            );
        }

        public static function LoadBySample($strParam1, $intParam2, $objOptionalClauses = null) {
            // This will return a single Person object
            return Person::QuerySingle(
                QQ::AndCondition(
                    QQ::Equal(QQN::Person()->Param1, $strParam1),
                    QQ::GreaterThan(QQN::Person()->Param2, $intParam2)
                ),
                $objOptionalClauses
            );
        }

        public static function CountBySample($strParam1, $intParam2, $objOptionalClauses = null) {
            // This will return a count of Person objects
            return Person::QueryCount(
                QQ::AndCondition(
                    QQ::Equal(QQN::Person()->Param1, $strParam1),
                    QQ::Equal(QQN::Person()->Param2, $intParam2)
                ),
                $objOptionalClauses
            );
        }

        public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses) {
            // Performing the load manually (instead of using Qcodo Query)

            // Get the Database Object for this Class
            $objDatabase = Person::GetDatabase();

            // Properly Escape All Input Parameters using Database->SqlVariable()
            $strParam1 = $objDatabase->SqlVariable($strParam1);
            $intParam2 = $objDatabase->SqlVariable($intParam2);

            // Setup the SQL Query
            $strQuery = sprintf('
                SELECT
                    `person`.*
                FROM
                    `person` AS `person`
                WHERE
                    param_1 = %s AND
                    param_2 < %s',
                $strParam1, $intParam2);

            // Perform the Query and Instantiate the Result
            $objDbResult = $objDatabase->Query($strQuery);
            return Person::InstantiateDbResult($objDbResult);
        }
*/



        // Override or Create New Properties and Variables
        // For performance reasons, these variables and __set and __get override methods
        // are commented out.  But if you wish to implement or override any
        // of the data generated properties, please feel free to uncomment them.
/*
        protected $strSomeNewProperty;

        public function __get($strName) {
            switch ($strName) {
                case 'SomeNewProperty': return $this->strSomeNewProperty;

                default:
                    try {
                        return parent::__get($strName);
                    } catch (QCallerException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                    }
            }
        }

        public function __set($strName, $mixValue) {
            switch ($strName) {
                case 'SomeNewProperty':
                    try {
                        return ($this->strSomeNewProperty = QType::Cast($mixValue, QType::String));
                    } catch (QInvalidCastException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                    }

                default:
                    try {
                        return (parent::__set($strName, $mixValue));
                    } catch (QCallerException $objExc) {
                        $objExc->IncrementOffset();
                        throw $objExc;
                    }
            }
        }
*/
    
}
?>

Start page:

Qcodo Development Framework 0.3.32 (Qcodo Beta 3)
Start Page

It worked!

If you are seeing this, then it means that the framework has been successfully installed. 


Make sure your database connection properties are up to date, and then you can add tables to your database, and go to either of the following webpages:
/_devtools/codegen.php - to code generate your tables
/form_drafts - to view the generated Form Drafts of your database
/examples - to run the Qcodo Examples Site locally
For more infromation, please go to the Qcodo website at: http://www.qcodo.com/ 


Qcodo Settings
QCODO_VERSION = "0.3.32 (Qcodo Beta 3)"
__SUBDIRECTORY__ = ""
__VIRTUAL_DIRECTORY__ = ""
__INCLUDES__ = "c:/www/vhosts/localhost/includes"
__QCODO_CORE__ = "c:/www/vhosts/localhost/includes/qcodo/_core"
ERROR_PAGE_PATH = "/assets/php/_core/error_page.php"
PHP Include Path = ".;C:/www/vhosts/localhost/;C:/www/php5/includes/"
QApplication::$DocumentRoot = "c:/www/vhosts/localhost"
QApplication::$EncodingType = "UTF-8"
QApplication::$PathInfo = ""
QApplication::$QueryString = ""
QApplication::$RequestUri = "/index.php"
QApplication::$ScriptFilename = "C:/www/vhosts/localhost/index.php"
QApplication::$ScriptName = "/index.php"
QApplication::$ServerAddress = "127.0.0.1"
QApplication::$Database[1] = array ( 'adapter' => 'MySqli5', 'server' => 'localhost', 'port' => NULL, 'database' => 'demo', 'username' => 'root', 'password' => 'pass', 'profiling' => false, )

DB was created from MySQL5 console (excecuted demo.sql)

#2  |  Eestlane Estonia
Monday, September 7, 2009, 11:13 PM PDT
CodeGen Settings (as evaluated from C:\www\vhosts\localhost\_devtools/codegen_settings.xml):

<codegen>
    <name application="My Application"/>
    <templateEscape begin="<%" end="%>"/>
    <dataSources>

        <database index="1">
            <className prefix="" suffix=""/>
            <associatedObjectName prefix="" suffix=""/>
            <typeTableIdentifier suffix="_type"/>
            <associationTableIdentifier suffix="_assn"/>
            <stripFromTableName prefix=""/>
            <excludeTables pattern="" list=""/>
            <includeTables pattern="" list=""/>
            <manualQuery support="false"/>
            <relationships>
            </relationships>
            <relationshipsScript filepath="" format="sql"/>
        </database>

    </dataSources>
</codegen>
Database Index #1 (MySql Improved Database Adapter for MySQL 5 (MySqli5) / localhost / demo)

There were 4 tables available to attempt code generation:

Successfully generated DB ORM Class:   Issue (with 4 relationships)
Successfully generated DB ORM Class:   Person (with 1 relationship)
Successfully generated DB ORM Class:   Project (with 1 relationship)
Successfully generated DB ORM Class:   Status (with no relationships)
Successfully generated Aggregate DB ORM file(s)
.bc
#3  |  Eestlane Estonia
Tuesday, September 8, 2009, 12:56 AM PDT

Another problem:


Panel Drafts -> Dashboard shows existing tabels and data, but adding new data gives the following error:

*An error occured during AJAX Responce parsing.

The error responce will appear in a new popup.*

When I try to open Panel Drafts -> issue -> View List I get error page:

mysqli::mysqli() [<a href='function.mysqli-mysqli'>function.mysqli-mysqli</a>]: (28000/1045): Access denied for user 'root'@'localhost' (using password: NO)
Error Type:   E_WARNING    

Source File:   C:\www\vhosts\localhost\includes\qcodo\database_adapters\QMySqliDatabase.inc         Line:   81    

Line 76:                $strUsername = QApplication::$ConnectionStringArray[$intDatabaseIndex]['username'];
Line 77:                $strPassword = QApplication::$ConnectionStringArray[$intDatabaseIndex]['password'];
Line 78:                $strPort = QApplication::$ConnectionStringArray[$intDatabaseIndex]['port'];
Line 79:    
Line 80:                // Connect to the Database Server
Line 81:                $this->objMySqli = new MySqli($strServer, $strUsername, $strPassword, $strName, $strPort);
Line 82:    
Line 83:                if (!$this->objMySqli)
Line 84:                    throw new QMySqliDatabaseException("Unable to connect to Database", -1, null);
Line 85:                
Line 86:                if ($this->objMySqli->error)

Call Stack: 

#0 (): QcodoHandleError()
#1 C:\www\vhosts\localhost\includes\qcodo\database_adapters\QMySqliDatabase.inc(81): mysqli->mysqli()
#2 C:\www\vhosts\localhost\includes\qcodo\framework_objects\QApplicationBase.inc(382): QMySqliDatabase->__construct()
#3 C:\www\vhosts\localhost\includes\prepend.inc(105): QApplicationBase::InitializeDatabaseConnections()
#4 C:\www\vhosts\localhost\form_drafts\issue_list.php(2): require_once()

And MySql5 and PHP5 is installed by Web-Developer Server Suite (similar program to Xampp).

EDIT

Problem solved:

Made fresh install and all worked (think I had some files from other Qcodo installation inside includes folder)...

#4  |  Vass Arpad (Szentegyháza, RO) Romania Qcodo Core Contributor
Tuesday, September 8, 2009, 3:18 AM PDT

well done then :)

if you have any further problems / questions, don't hesitate to post them.

kind regards,

Arpi.



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.