17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1311 Views |
-
SQLQuery()

11 July 2008 at 11:25pm
Hi,
I'm trying to generate a custom query so I can specify the date format and possibly group a result set. here is my code:
$sqlQuery = new SQLQuery();
$sqlQuery->select = array('YEAR(StartDate) AS Date');
$sqlQuery->from = "ProjectItem";
$rawSQL = $sqlQuery->sql();
$result = $sqlQuery->execute();I'm trying to select the StartDate from my 'ProjectItem' table.
The problem is the query returns an error:
FATAL ERROR: implode() [function.implode]: Invalid arguments passed
I'm pretty sure its the 'from' clause, my table exists and the fields are correct.
Anybody know where i'm going wrong.
Thanks in advance
-
Re: SQLQuery()

14 July 2008 at 3:56pm
->select and ->from should be arrays
Try changing the two lines to this:
$sqlQuery->select[] = array('YEAR(StartDate) AS Date');
$sqlQuery->from[] = "ProjectItem"; -
Re: SQLQuery()

6 September 2008 at 1:41am Last edited: 6 September 2008 1:42am
Hi,
I am trying this query$sqlQuery = new SQLQuery();
$sqlQuery->select = array(
'ProductName AS ProductName',
'Industry AS Industry',
'Type AS Type',
'Serving AS Serving',
'Info AS Info',
'ReviewsBuzz AS ReviewsBuzz',
'Technology AS Technology',
'WhatsCooking AS WhatsCooking'
);
$sqlQuery->from[] = "
SubProducts
";
$sqlQuery->where[] = "
ID = 1";
// get the raw SQL
$rawSQL = $sqlQuery->sql();
echo $rawSQL;
// execute and return a Query-object
return $result = $sqlQuery->execute();But it did not return any thing ...
i tried this as echoing echo $rawSQL;SELECT ProductName AS ProductName, Industry AS Industry, Type AS Type, Serving AS Serving, Info AS Info, ReviewsBuzz AS ReviewsBuzz, Technology AS Technology, WhatsCooking AS WhatsCooking FROM SubProducts WHERE ( ID = 1)
this is working fine in phpmyadmin ...
Also i triedecho "<pre>";
print_r($result);
echo "</pre>";
it display meMySQLQuery Object
(
[database:private] => MySQLDatabase Object
(
[dbConn:private] => Resource id #89
[active:private] => 1
[database:private] => SS_mysite
[mysqlVersion:private] =>
[tableList:protected] =>
[fieldList:protected] =>
[indexList:protected] =>
[schemaUpdateTransaction:protected] =>
[extension_instances:protected] => Array
(
)[class] => MySQLDatabase
)[handle:private] => Resource id #132
[currentRecord:private] =>
[rowNum:private] => -1
[extension_instances:protected] => Array
(
)[class] => MySQLQuery
)i am not getting how to get result from this ...
Please help me ...
Thanks in Advance
| 1311 Views | ||
|
Page:
1
|
Go to Top |


