Login | Register
My pages Projects Community openCollabNet

Discussions > dev > [propel-dev] Custom SQL | Can't make it work :/

Discussion topic

Back to topic list

[propel-dev] Custom SQL | Can't make it work :/


Author tlcbremen <schmidt at tlc-communications dot de>
Full name tlcbremen <schmidt at tlc-communications dot de>
Date 2008-03-20 08:43:07 PDT
Message hi!

im having a little problem making custom SQL queries work in my test propel
application. i am new to propel so it might be a pretty stupid error :/
today, i installed propel 1.3 (beta) and did a building job on an existing
database. everything worked pretty well. concerning CRUD, i did some simple
propel queries, which also worked well.

however, i also wanted to try out custom SQL queries because i am sure i
will need them if i decide to use propel in the next project. the code i use
to do the custom SQL query is at the bottom of this post. when i execute it,
ill get the following error message: PropelException: No connection
information in your runtime configuration file for datasource
C:\xampp\php\apps​\propel\runtime\c​lasses\propel\Prop​el.php on line 520
apparently he doesnt know the constant DATABASE_NAME. when write the
datasource name diretcly >> $con = Propel::getConnection("test"); << i get
an error like this:
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table
'ml_db_dev.ml_db_dev' doesn't exist in ...

did i forget to include anything or set any configuration settings which are
needed to do customt SQL queries? i did it exactly like in the propel docs.

would be really glad if someone could give me a hint!

thanks a lot in advance!

infos you might need:
# build.properties
    propel.project = test
    propel.database = mysql
    propel.database.url = mysql:host=192.168.1​.2;dbname=ml_db_dev

# runtime-conf.xml
    <datasources default="test">
           <datasource id="test">
                    <setting id="charset">utf8​</setting>
                    <option id="ATTR_EMULATE_PRE​PARES">true</o​ption>

code which i used to try a simple custom SQL query:

// Set the includes
    // Path to propel main class
    set_include_path('C:​\xampp\php\apps\​propel\runtime\cla​sses' .
PATH_SEPARATOR . get_include_path());

    // Build objects

. PATH_SEPARATOR . get_include_path());
// Include of propel base class
require_once 'propel/Propel.php';
// propel init
// #### Custom SQL query - Test ####

$con = Propel::getConnectio​n(DATABASE_NAME);
$sql = "SELECT ml_db_dev.* FROM ml_db_dev WHERE id=1";
$stmt = $con->prepare($sql);
$test = TestPeer::populateOb​jects($stmt);

View this message in context: http://www.nabble.co​m/Custom-SQL-%7C-Can​%27t-make-it-work-%3​A--tp16181659p161816​59.html
Sent from the propel - dev mailing list archive at Nabble.com.

« Previous message in topic | 1 of 1 | Next message in topic »


Show all messages in topic

[propel-dev] Custom SQL | Can't make it work :/ tlcbremen <schmidt at tlc-communications dot de> tlcbremen <schmidt at tlc-communications dot de> 2008-03-20 08:43:07 PDT
Messages per page: