TODO: This example is a fragment, must be completed.
These are the steps you have to do
All scripts for this demo are located in misc/demoSqlConnect.
TODO
cd /opt/mika/misc/demoSqlConnect mysql -u root -p mika < mika-demo.sql
After installing the database, database 'backend' includes one table 'customers' which contains two demo recordsets. This data is shown on the smartphone finally.
Please adjust the connection settings to reach the mysql database 'backend' which was created before in file
lib/backends/BasicSqlConnect.php: $dbServer, $dbName, $dbUsername, $dbPassword
TODO
mysqladmin -u root -p create backend mysql -u root -p < database-customers.sql
see ../INSTALL-CLIENT
Login to mika client (username: demo, password: demo). After login start Application SqlDemo.
Screenshot
This is the data stored in our demo application database
mysql> select * from customers; +----+-----------------+----------+---------------+ | ID | customerName | address | lastYearSales | +----+-----------------+----------+---------------+ | 1 | Big Foo Company | New York | 12054.23 | | 2 | Small Bar Ltd. | Detroid | 6143.52 | +----+-----------------+----------+---------------+ 2 rows in set (0.34 sec)
To customize the sql query go to bin/backends/BasicSqlConnect in line 111 and set the query to your backend table. Second you have to configure the output regarding to the selected table columns in line 123.
switch ($view) { case "start": [...] case "customers": $sql = 'SELECT * ' . 'FROM `customers` ' . 'ORDER BY `customers`.`lastYearSales` DESC ' . 'LIMIT 0 , 30'; $this->mika->logger->logDebug("sql: " . $sql); $result = mysql_query($sql, $this->dbConnection); $data = array(); while($row = mysql_fetch_assoc($result)) { $data = array_merge($data, array( array( "id" => 1, "text" => $row['customerName'] . ' | ' . $row['address'] . ' | ' . $row['lastYearSales'], "active" => 1 ) )); } [...]