[owncloud-devel] Problems in fetching data via .load in script.js

Vincent Petry pvince81 at owncloud.com
Tue Nov 3 16:15:44 GMT 2015


Hi,

You should not connect to the database directly because not everybody
uses MySQL with ownCloud.

Please use \OC::$server->getDatabaseConnection() which gives you an
abstract database connection from which you can execute your SQL statements.

See
https://github.com/owncloud/core/blob/v8.2.0/lib/private/allconfig.php#L211
for an example

Cheers,

Vincent

On 18.10.2015 19:11, andy wrote:
> Hi all,
>
>  
>
> I am about to integrate a more complex open source JS app into owncloud.
> Main steps are done so far but I am stuck on receiving data from the
> database. The script calls the data via .load("data.php"). Including just
> data.php in the part.content.php is working but leaving the
> .load("data.php") in the script results in nothing. The script itself ist
> running without any problems outside of owncloud. 
>
>  
>
> The data.php file looks like
>
>  
>
> <?php
>
> $oc_host = OC::$server->getSystemConfig()->getValue('dbhost', false);
>
> $oc_user = OC::$server->getSystemConfig()->getValue('dbuser', false);
>
> $oc_password = OC::$server->getSystemConfig()->getValue('dbpassword',
> false);
>
> $oc_name = OC::$server->getSystemConfig()->getValue('dbname', false);
>
> $link_table = OC::$server->getSystemConfig()->getValue('dbtableprefix',
> false).'owngantt_links';
>
> $task_table = OC::$server->getSystemConfig()->getValue('dbtableprefix',
> false).'owngantt_tasks';
>
>  
>
> $res=mysql_connect($oc_host,$oc_user,$oc_password);
>
> mysql_select_db($oc_name);
>
>  
>
> include ('apps/owngantt/codebase/connector/gantt_connector.php');
>
>  
>
> $gantt = new JSONGanttConnector($res);
>
>  
>
> $gantt->render_links($link_table,"id","source,target,type");
>
> $gantt->render_table(
>
>    $task_table,
>
>    "id",
>
>    "start_date,duration,text,progress,sortorder,parent"
>
> );
>
>  
>
>  
>
> ?>
>
>  
>
> Has anybody any ideas what should I do to get the things running?
>
>  
>
> Thx!
>
>  
>
> Andy
>
>
>
>
> _______________________________________________
> Devel mailing list
> Devel at owncloud.org
> http://mailman.owncloud.org/mailman/listinfo/devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.owncloud.org/pipermail/devel/attachments/20151103/cf2eb77b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.owncloud.org/pipermail/devel/attachments/20151103/cf2eb77b/attachment.sig>


More information about the Devel mailing list