示例#1
0
function DBUCKET($db, $sql)
{
    $search = array('CAN I PLZ GET ', ' ALL UP IN ', ' OMG ');
    $replace = array('SELECT ', ' FROM ', ' WHERE ');
    $sql = str_replace($search, $replace, $sql);
    return sqlite_array_query($db, $sql);
}
 function loadIndexes()
 {
     if (!$this->isExisting || $this->isIndexesLoaded) {
         return;
     }
     $this->loadColumns();
     $connection_id = $this->database->getConnection()->getConnectionId();
     $rs = sqlite_array_query($connection_id, "PRAGMA index_list('{$this->name}')", SQLITE_ASSOC);
     foreach ($rs as $item) {
         $index = new lmbSqliteIndexInfo();
         $index->table = $this;
         $index->name = $item['name'];
         list($index_info) = sqlite_array_query($connection_id, "PRAGMA index_info('{$index->name}')", SQLITE_ASSOC);
         $index->column_name = $index_info['name'];
         if (1 == $item['unique']) {
             // if column is defined exactly as INTEGER PRIMARY KEY, primary index is not created
             // instead it becomes an alias of system ROWID, see http://www.sqlite.org/lang_createtable.html#rowid for more info
             $index->type = in_array($index['column_name'], $this->pk) ? lmbDbIndexInfo::TYPE_PRIMARY : lmbDbIndexInfo::TYPE_UNIQUE;
         } else {
             $index->type = lmbDbIndexInfo::TYPE_COMMON;
         }
         $this->indexes[$index->name] = $index;
     }
     $this->isIndexesLoaded = true;
 }
 function array_query($sqlString, $result_type = SQLITE_BOTH, $decode_binary = true)
 {
     if (DEBUG) {
         return sqlite_array_query($this->connId, $sqlString, $result_type, $decode_binary);
     } else {
         return @sqlite_array_query($this->connId, $sqlString, $result_type, $decode_binary);
     }
 }
示例#4
0
文件: SQLite.php 项目: mmr/b1n
 /**
  * Executes a query that might return just one row.
  * @param $query the query.
  * @return an array with the requested row data.
  */
 public function singleQuery($query)
 {
     checkQuery($query);
     #echo "$query\n";
     $ret = sqlite_array_query($query, $this->link, SQLITE_ASSOC);
     if (count($ret)) {
         return $ret[0];
     }
 }
示例#5
0
 public function iteratorKeys()
 {
     $data = sqlite_array_query($this->db, 'SELECT keystr FROM is4c_local', SQLITE_NUM);
     $keys = array();
     foreach ($data as $row) {
         $keys[] = $row[0];
     }
     return array_merge(parent::iteratorKeys(), $keys);
 }
示例#6
0
文件: fuu.php 项目: aimxhaisse/fuu
function get_stats()
{
    global $db;
    $query = "SELECT SUM(nb_view) AS nb_views, SUM(nb_play) AS nb_plays FROM fuu WHERE 1";
    $res = sqlite_array_query($db, $query, SQLITE_ASSOC);
    if (count($res) > 0) {
        return $res[0];
    }
    return array('nb_views' => 0, 'nb_plays' => 0);
}
示例#7
0
文件: SQLite.php 项目: mmr/b1n
 public function SingleQuery($query)
 {
     if (!$this->IsConnected()) {
         throw new Exception("Not Connected to DB.");
     }
     #echo "$query\n";
     $ret = sqlite_array_query($query, $this->link, SQLITE_ASSOC);
     if (count($ret)) {
         return $ret[0];
     }
 }
 public function getProducts()
 {
     try {
         $db = new dbHandler();
         $link = $db->getDbHandler();
         /*String*/
         $query = "SELECT Name, Price FROM Products";
         $result = sqlite_array_query($link, $query, SQLITE_ASSOC);
         $db->close();
         return $result;
     } catch (Exception $exception) {
         Log::log(LoggingConstants::EXCEPTION, $exception);
     }
     return null;
 }
示例#9
0
function getRecords()
{
    global $dbPath, $dbHandle;
    if ($dbHandle == 0) {
        $dbHandle = sqlite_open($dbPath, 0666, $sqliteError) or die("SQL error: {$sqliteError}");
    }
    //NO! $ra = sqlite_fetch_array(dbQuery("select id from list"));
    $ra = sqlite_array_query($dbHandle, 'SELECT * FROM list LIMIT 200');
    /*
    	echo "<pre>\n";
    	print_r($ra);
    	echo "<pre>\n";
    	
    	//var_dump(sqlite_fetch_array($result));
    */
    return $ra;
}
示例#10
0
	echo "Time Taken: ".($e-$s)."\n";


	$s = getmicrotime();
	$r = sqlite_unbuffered_query("SELECT * FROM foo", $db);
	while (sqlite_fetch_array($r, SQLITE_NUM));
	$e = getmicrotime();
	echo "Time Taken: ".($e-$s)."\n";

	$db = new sqlite_db("db2.sqlite");

	$s = getmicrotime();
	$r = $db->unbuffered_query("SELECT * FROM foo", SQLITE_NUM);
	foreach($r as $row);
	$e = getmicrotime();
	echo "Time Taken: ".($e-$s)."\n";


	sqlite_query("DROP TABLE messages", $db);
	sqlite_query("CREATE TABLE messages ( timestamp INTEGER, title VARCHAR(255) )", $db);
	sqlite_query("DROP TABLE profile", $db);
	sqlite_query("CREATE TABLE profile ( time_format VARCHAR(255), login VARCHAR(255) )", $db);
	sqlite_query("INSERT INTO profile (login, time_format) VALUES('ilia', 'l dS of F Y h:i:s A')", $db);
	for ($i = 0; $i < 5; $i++) {
		sqlite_query("INSERT INTO messages (timestamp, title) VALUES(".rand(time(), (time() + 86400 * 365)).", 'message #{$i}')", $db);
	}
*/
sqlite_query("PRAGMA show_datatypes = ON", $db);
//	sqlite_query("PRAGMA full_column_names = ON", $db);
print_r(sqlite_array_query("SELECT * FROM messages", $db));
sqlite_close($db);
示例#11
0
文件: newAPI.php 项目: johntdyer/SBC
			echo "<rejectWithBusy>".checkRejectWithBusy()."</rejectWithBusy>";
			echo "<ifRecordFound>".getOnANIMatchCondition()."</ifRecordFound>";
				if(getOnANIMatchCondition()=="acceptCall"){
					print('<rejectCallWithBusy value="false">'	.	getRedirectRoute("acceptCall")	.	'</rejectCallWithBusy>');
				}else{
					if(checkRejectWithBusy()=='false'){
						print('<rejectCallWithBusy value="false">'	.	getRedirectRoute("rejectCall")	.	'</rejectCallWithBusy>');	
					}else{
						print('<rejectCallWithBusy value="true"/>');
					}
				}
	
				echo("<queryResults recordsFound=\"".$recordsFound."\">");
				echo('<!-- Multiple Records Found-->');
				// Print out records found if there are more then one

				$query = "SELECT * FROM userRecords WHERE (ANI='".$_REQUEST['callerID']."') ORDER BY 1 DESC";	
				$dbhandle = sqlite_open($dbPath,0666);
				$result = sqlite_array_query($dbhandle,$query, SQLITE_ASSOC);

				foreach ($result as $entry) {
					echo "<recordName number=\"" . $recordCounterVar . "\">". ($entry['firstName'])." ".($entry['lastName']). "</recordName>";
					$recordCounterVar++;
				}
				echo "</queryResults>";
			}

			print('</xmlData>');
			exit;
?>
示例#12
0
文件: login.php 项目: lflores10/octa
<?php

require "../config/main.php";
$rows = sqlite_array_query($dbmain, "SELECT database,nombre FROM tbempresas where codigo='" . $_POST["login-empresa"] . "' limit 1", SQLITE_ASSOC);
foreach ($rows as $row) {
    mssql_select_db($row[database]);
    ///falta la clave
    $sql = mssql_query("select OBJECT_ID('dbo.VBENCRIPTA')");
    if (mssql_result($sql, 0, 0) == '') {
        mssql_query("\n\t\t\tCREATE FUNCTION [dbo].[VBENCRIPTA](@str VARCHAR(50))\n\t\t\tRETURNS VARCHAR(50)\n\t\t\tAS\n\t\t\tBEGIN\n\t\t\t\tdeclare @istr as int;\n\t\t\t\tdeclare @strend as nvarchar(50);\n\t\t\t\tset @istr = 0;\n\t\t\t\tset @strend = '';\n\t\t\t\twhile len(@str)>@istr\n\t\t\t\tbegin\n\t\t\t\t\tset @strend = @strend + CHAR(ASCII(substring(@str,@istr+1,1))+80);\n\t\t\t\t\tset @istr = @istr+1;\n\t\t\t\tend\n\t\t\t\treturn @strend;\n\t\t\tEND");
    }
    if ($sql = @mssql_query("select * from tbusuarios where LOGIN='******' and CLAVE=dbo.VBENCRIPTA('" . $_POST["login-pass"] . "') and inactivo=0")) {
        if (mssql_num_rows($sql) > 0) {
            $rowu = sqlite_array_query($dbmain, "SELECT * FROM tbsession where user='******' limit 1", SQLITE_ASSOC);
            if (count($rowu) == 0 || time() - $rowu[0][time] > 25) {
                sqlite_exec($dbmain, "delete from tbsession where user='******'");
                sqlite_exec($dbmain, "insert into tbsession (id,user,time) values ('" . session_id() . "','" . md5(strtoupper($_POST["login-user"])) . "','" . time() . "')");
                session_register("octa-lite-empresa");
                $_SESSION["octa-lite-empresa"]["codigo"] = $_POST["login-empresa"];
                $_SESSION["octa-lite-empresa"]["database"] = $row[database];
                $_SESSION["octa-lite-empresa"]["nombre"] = $row[nombre];
                session_register("octa-lite-user");
                $_SESSION["octa-lite-user"] = mssql_fetch_array($sql, MSSQL_ASSOC);
                $_SESSION["octa-lite-user"]["CLAVE"] = "+++++";
                echo "logged";
            } else {
                echo utf8_encode("Este usuario ya esta activo en otro equipo!");
            }
        } else {
            echo "Contrase&ntilde;a inv&aacute;lida!";
        }
示例#13
0
 /**
  * Returns information about a table
  *
  * @param string         $result  a string containing the name of a table
  * @param int            $mode    a valid tableInfo mode
  *
  * @return array  an associative array with the information requested.
  *                 A DB_Error object on failure.
  *
  * @see DB_common::tableInfo()
  * @since Method available since Release 1.7.0
  */
 function tableInfo($result, $mode = null)
 {
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         $id = @sqlite_array_query($this->connection, "PRAGMA table_info('{$result}');", SQLITE_ASSOC);
         $got_string = true;
     } else {
         $this->last_query = '';
         return $this->raiseError(DB_ERROR_NOT_CAPABLE, null, null, null, 'This DBMS can not obtain tableInfo' . ' from result sets');
     }
     if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     $count = count($id);
     $res = array();
     if ($mode) {
         $res['num_fields'] = $count;
     }
     for ($i = 0; $i < $count; $i++) {
         if (strpos($id[$i]['type'], '(') !== false) {
             $bits = explode('(', $id[$i]['type']);
             $type = $bits[0];
             $len = rtrim($bits[1], ')');
         } else {
             $type = $id[$i]['type'];
             $len = 0;
         }
         $flags = '';
         if ($id[$i]['pk']) {
             $flags .= 'primary_key ';
             if (strtoupper($type) == 'INTEGER') {
                 $flags .= 'auto_increment ';
             }
         }
         if ($id[$i]['notnull']) {
             $flags .= 'not_null ';
         }
         if ($id[$i]['dflt_value'] !== null) {
             $flags .= 'default_' . rawurlencode($id[$i]['dflt_value']);
         }
         $flags = trim($flags);
         $res[$i] = array('table' => $case_func($result), 'name' => $case_func($id[$i]['name']), 'type' => $type, 'len' => $len, 'flags' => $flags);
         if ($mode & DB_TABLEINFO_ORDER) {
             $res['order'][$res[$i]['name']] = $i;
         }
         if ($mode & DB_TABLEINFO_ORDERTABLE) {
             $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
         }
     }
     return $res;
 }
示例#14
0
<?php

$db = sqlite_open(dirname(__FILE__) . "/db2.sqlite");
/* arguments:
 * 1 database resource
 * 2 sqlite function name
 * 3 php function name
 * 4 number of arguments (optional)
 */
sqlite_create_function($db, "my_date", "date", 2);
/* 
 * The above function makes PHP date() avaliable 
 * from SQLite as my_date() and for highest 
 * performance indicates that it requires 
 * exactly 2 arguments 
 */
$res = sqlite_array_query("\n\tSELECT title, \n\tmy_date((SELECT time_format FROM profile WHERE login='******'), timestamp) AS date\n\tFROM messages", $db, SQLITE_ASSOC);
foreach ($res as $v) {
    echo $v['title'] . " was posted on " . $v['date'] . "<br />\n";
}
示例#15
0
 public function queryAll($sql)
 {
     $result = sqlite_array_query($this->lnk, $sql, SQLITE_ASSOC);
     return $result;
 }
示例#16
0
文件: piwik.php 项目: klando/pgpiwik
if ($dbhandle) {
    // SQLite 3.3 supports CREATE TABLE IF NOT EXISTS
    $result = sqlite_array_query($dbhandle, "SELECT COUNT(*) FROM requests");
    if ($result === false) {
        try {
            $query = sqlite_exec($dbhandle, 'CREATE TABLE requests (token TEXT, ip TEXT, ts TEXT, uri TEXT, referer TEXT, ua TEXT);');
        } catch (Exception $e) {
        }
    }
}
if (isset($_GET['results'])) {
    $token = $_GET['results'];
    $ua = $_SERVER['HTTP_USER_AGENT'];
    echo "<html><head><title>{$token}</title></head><body>\n";
    //	$result = sqlite_array_query($dbhandle, "SELECT uri FROM requests");
    $result = sqlite_array_query($dbhandle, "SELECT uri FROM requests WHERE token = \"{$token}\" AND ua = \"{$ua}\"");
    if ($result !== false) {
        $nofRows = count($result);
        echo "<span>{$nofRows}</span>\n";
        foreach ($result as $entry) {
            echo "<span>" . $entry['uri'] . "</span>\n";
        }
    }
    echo "</body></html>\n";
} else {
    if (!isset($_GET['data'])) {
        header("HTTP/1.0 400 Bad Request");
    } else {
        $data = json_decode($_GET['data']);
        $token = isset($data->token) ? $data->token : '';
        $ip = $_SERVER['REMOTE_ADDR'];
示例#17
0
<?php

$b = sqlite_array_query($db, "SELECT * FROM bar WHERE id=(SELECT id FROM foo WHERE name='ilia')");
示例#18
0
<?php

$con = sqlite_open("pos.db", 0666, $e);
if ($e) {
    die("db error");
}
$sql = "select * from pos";
$data = sqlite_array_query($con, $sql, SQLITE_ASSOC);
sqlite_close($con);
$json = json_encode($data);
header("Content-Type: application/json");
echo $json;
示例#19
0
<?php

require "../config/main.php";
$rows = sqlite_array_query($dbmain, "SELECT * FROM tbempresas", SQLITE_ASSOC);
foreach ($rows as $row) {
    mssql_select_db($row[database]);
    if ($sql = mssql_query("select count(*) from tbusuarios where login='******'")) {
        $count = mssql_result($sql, 0, 0);
        if ($count > 0) {
            $logbase[$row[codigo]][id] = $row[codigo];
            $logbase[$row[codigo]][nombre] = $row[nombre];
        }
    }
}
///*$sql=mssql_query("SELECT * FROM master.dbo.sysdatabases");
echo json_encode($logbase);
mssql_close();
end;
示例#20
0
<?php

chdir(dirname(__FILE__));
// pres2 hack
$ip_int = sprintf("%u", ip2long("24.100.195.79"));
$db = sqlite_open("./ip.db");
// attach to another database
sqlite_query("ATTACH DATABASE './flag.db' AS 'flags'", $db);
$data = sqlite_array_query($db, "\nSELECT country_name, flag_file\nFROM ip_ranges ir \nINNER JOIN country_data cd ON ir.country_code=cd.id\nINNER JOIN flags.flag_db f ON f.country_id=cd.id\nWHERE {$ip_int} BETWEEN ip_start AND ip_end", SQLITE_ASSOC);
// detach from attached database
sqlite_query("DETACH DATABASE flags", $db);
echo "User is located in {$data[0]['country_name']}";
// pres2 hackery
$path = dirname($_SERVER['PHP_SELF']) . "/../../presentations/slides/sqlite_adm/";
echo " <img src='{$path}{$data[0]['flag_file']}' />";
示例#21
0
 public function findPlayListItem($type = CONTENT_SHOW, $timeslot = "other", $show = "", $bumperType = "", $rotationType = "", $maxTimeToFill = 0)
 {
     // 1: search for content
     // 2: select the content that is least played, and first in queue
     // 3: create a playlistitem
     // 4: update the database that this file is queued
     // its a show we are after, so lets search one we haven't played yet, and matches the thing we want to see.
     if (!empty($show)) {
         // only play the least broadcasted shows. The counter should increment once per season. So when you played everything from one season, it starts over.
         // sqlite doesnt do min and max
         /// episode 1 played 5 times
         /// episode 2 played 5 times
         /// episode 3 played 4 times
         /// episode 4 played 4 times
         // will get episode 3. In case all have been played the same number, it gets episode 1.
         // SQLITE doesnt do MIN or MAX in decent queries, so we have to walk through the resultset to determine the minimum play count value
         $foundContent = array();
         $sql = "select * from content \n                    where showName = '" . $show->get_name() . "' \n                        and timeslot = '" . $show->get_timeslot() . "' \n                        and category= '" . CONTENT_SHOW . "' \n                    order by filename ASC, statistics_playcount ASC;";
         $foundContent = sqlite_array_query($this->db, $sql);
         // in case the show is not in the crrect timeslot, we have to check the "other" directory...
         /**
              
                         showName = '".$show->get_name()."' 
                         and timeslot = 'other' 
                         and 
         */
         if (empty($foundShows)) {
             $sql = "select * from content \n                        where showName = '" . $show->get_name() . "' \n                            and timeslot = 'other' \n                            and category = '" . CONTENT_SHOW . "' \n                        order by filename ASC, statistics_playcount ASC;";
             $foundContent = sqlite_array_query($this->db, $sql);
             //print $sql;
             //print_r($foundContent);
         }
     }
     // other content might have a time constraint...
     if ($maxTimeToFill > 0) {
         $timeConstraint = " and metadata_duration_in_seconds <= " . $maxTimeToFill . " ";
     } else {
         // no time limitations...
         $timeConstraint = "";
     }
     // if its not a show then we might choose from two nearly the same random pools: funny movies and commercials. Both implementations
     // look a lot like previous code... so an abstraction will be possible. (this has no showname)
     if ($type == CONTENT_COMMERCIAL or $type == CONTENT_FUNNY) {
         // verwacht hier een paar 100 commercials, jammer dat MIN niet werkt...
         // ordering filenames hoeft niet, het mag random (maar dat ondersteunt sqllite ook niet.)
         $foundContent = array();
         $sql = "select * from content \n                    where timeslot = '" . $timeslot . "' \n                        and category= '" . $type . "' \n                        " . $timeConstraint . "\n                    order by RANDOM(), statistics_playcount ASC;";
         $foundContent = sqlite_array_query($this->db, $sql);
         if (empty($foundContent)) {
             $sql = "select * from content \n                        where timeslot = 'other' \n                            and category= '" . $type . "' \n                            " . $timeConstraint . "\n                        order by RANDOM(), statistics_playcount ASC;";
             $foundContent = sqlite_array_query($this->db, $sql);
         }
     }
     // Bumper types:
     // Commercial_Start
     // Commercial_End
     // StationPromo
     if ($type == CONTENT_BUMPER) {
         $foundContent = array();
         $sql = "select * from content \n                    where timeslot = '" . $timeslot . "' \n                        and category= '" . $type . "' ";
         if ($bumperType == BUMPER_COMMERCIAL_END || $bumperType == BUMPER_COMMERCIAL_START) {
             $sql .= "and showName like '%" . $bumperType . "%'";
         } else {
             $sql .= "and showName not like '%" . $bumperType . "%'";
         }
         $sql .= "" . $timeConstraint . "\n                    order by RANDOM(), statistics_playcount ASC;";
         $foundContent = sqlite_array_query($this->db, $sql);
         if (empty($foundContent)) {
             $sql = "select * from content \n                        where timeslot = 'other' \n                            and category= '" . $type . "' ";
             if ($bumperType == BUMPER_COMMERCIAL_END || $bumperType == BUMPER_COMMERCIAL_START) {
                 $sql .= "and showName like '%" . $bumperType . "%'";
             } else {
                 $sql .= "and showName not like '%" . $bumperType . "%'";
             }
             $sql .= "" . $timeConstraint . "\n                        order by RANDOM(), statistics_playcount ASC;";
             $foundContent = sqlite_array_query($this->db, $sql);
         }
     }
     // announcements worden on the fly gemaakt, met een custom tijdspanne afhankelijk van de lengte van de bumpers enzo. Dat is de dynamische tijdvuller.
     // noooooo!!! its impossible... just download some stuff from youtube and get your stuff in order
     // no show to our liking? then just fill the time being with commercials and funny movies...
     // this might call for a better database updating algorithm. (or we can write a file with playcount per show, but thats anoying)
     $showName = "";
     if (!empty($show)) {
         $showName = $show->get_name();
     }
     if (empty($foundContent)) {
         print "Warning: Could not find a contentitem with these parameters: " . "ContentType: " . $type . " - Timeslot: " . $timeslot . " - Show: " . $showName . " -  Bumpertyupe:" . $bumperType . " - Rotation:" . $rotationType . " - Length: " . $maxTimeToFill . " \n";
         //debug_print_backtrace();
         // an empty playlistitem can be used to break out the while loop looking for content.
         $emptyPlayListItem = new playListItem();
         $emptyPlayListItem->fileLocation = "";
         $emptyPlayListItem->debugInfo = "Could not find a contentitem with these parameters: " . "ContentType: " . $type . " - Timeslot: " . $timeslot . " - Show: " . $showName . " -  Bumpertyupe:" . $bumperType . " - Rotation:" . $rotationType . " - Length: " . $maxTimeToFill . "";
         return $emptyPlayListItem;
     }
     // this is like an infinite loop now...
     //print "we found content!";
     // var_dump($foundContent); // niet alles tonen, tis nogal veel...
     //print_r($foundContent);
     // now we have to traverse the shows to see what is the lowest playcount
     $lowestPlayCount = 90000;
     foreach ($foundContent as $content) {
         if ($content['statistics_playcount'] < $lowestPlayCount) {
             $lowestPlayCount = $content['statistics_playcount'];
         }
     }
     // now we get the first show with this awesome low playcount
     foreach ($foundContent as $content) {
         if ($content['statistics_playcount'] == $lowestPlayCount) {
             $playListItem = new playListItem();
             $playListItem->fileLocation = $content['filename'];
             $playListItem->duration = $content['metadata_duration_in_seconds'];
             $playListItem->debugInfo = "Found: " . $content['filename'] . "  ContentType: " . $type . " - Timeslot: " . $timeslot . " - Show: " . $showName . " - Bumpertyupe:" . $bumperType . " - Rotation:" . $rotationType . " - Length: " . $maxTimeToFill . "";
         }
     }
     // TODO: filelocation is nog leeg hier...
     // debug...
     //print "Found content item. Duration: ".$playListItem->duration." filelocation:".$playListItem->fileLocation." \n";
     if ($playListItem->duration == 0) {
         /*print "warning: you are trying to retrieve content that doesn't fill the timeslot \n".
           "ContentType: ".$type." - Timeslot: ".$timeslot.
           " - Show: ".$showName." -  Bumpertyupe:".$bumperType.
           " - Rotation:".$rotationType." - Length: ".$maxTimeToFill." \n";*/
     }
     //var_dump($playListItem);
     // update the database
     $sql = "UPDATE content SET statistics_playcount = " . ($lowestPlayCount + 1) . " WHERE id = " . $content['id'] . ";";
     sqlite_query($this->db, $sql);
     // done!
     return $playListItem;
 }
<?php

sqlite_array_query("handle", "SELECT * FROM table WHERE field='{$_GET['query']}'");
示例#23
0
<?php

$db = sqlite_open(dirname(__FILE__) . "/db.sqlite");
echo '<pre>';
/* array sqlite_array_query(string query, resource db [ , int result_type [, bool decode_binary]]) */
var_dump(sqlite_array_query("SELECT * FROM auth_tbl", $db, SQLITE_ASSOC));
echo '</pre>';
sqlite_close($db);
示例#24
0
function ping()
{
    global $dbmain;
    /*
    $sql=mssql_query("select codigo_cit,
    (select nombre_pac from tbpacientes where codigo_pac=paciente_cit) as nombre,
    (select rtrim(ltrim(codareatel1_pac))+rtrim(ltrim(telefono1_pac)) from tbpacientes where codareatel1_pac like '04%' and codigo_pac=paciente_cit) as telefono,
    (select nombre_prv from tbproveedores where codigo_prv=proveedor_cit) as medico,
    dbo.GetDayName(fecha_cit) dial,
    day(fecha_cit) dian,
    datename(month,fecha_cit) mes,
    year(fecha_cit) anno
    from tbcitas where isnull(sms_cit,0)=0 
    and isnull((select codareatel1_pac+telefono1_pac from tbpacientes where codareatel1_pac like '04%' and codigo_pac=paciente_cit),'') <> ''");
    if(mssql_num_rows($sql)>0){
    	$i=0;
    	$datasms["key"]='4eac12fbfe5c923d67f1fd904ac04d19';
    	$datasms["cli"]="J313611069";
    	$rifcli=$datasms["cli"];		
    	while($row=mssql_fetch_array($sql)){
    		$datasms["sms"][$i]["t"]=preg_replace("/[^0-9]/","",$row["telefono"]);
    		$datasms["sms"][$i]["m"]=utf8_decode(utf8_encode("Sr(a) ".stripAccents(utf8_encode($row[nombre])).", registramos su cita para el ".stripAccents(utf8_encode($row[dial]))." ".$row[dian]." de ".$row[mes]." con el Dr(a). ".stripAccents(utf8_encode($row[medico])).", su codigo de confirmacion es: ".$row[codigo_cit]));
    		$datasms["sms"][$i]["s"]="true";
    		mssql_query("update tbcitas set sms_cit = getdate() where codigo_cit='".$row["codigo_cit"]."'");
    		$i++;
    	}
    	if(count($datasms)>0){
    		$json=urlencode(base64_encode(json_encode($datasms)));
    		$ch = curl_init();
    		curl_setopt($ch,CURLOPT_URL, 'http://rtx.w3sistemas.com/sms/send/massive.php?key=4eac12fbfe5c923d67f1fd904ac04d19&cli='.$rifcli);
    		curl_setopt($ch,CURLOPT_POST, 1);
    		curl_setopt($ch,CURLOPT_USERPWD,"w3sms:sistemaoctartx");
    		curl_setopt($ch,CURLOPT_POSTFIELDS, 'data='.$json);
    		curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
    		curl_setopt($ch,CURLOPT_TIMEOUT,10000);
    		$result = curl_exec($ch);
    		curl_close($ch);
    	}
    }
    
    $sql=mssql_query("select codigo_cit,
    (select codigo_cit from tbcitas2 where notificado_cit=0 and convert(nvarchar,tbcitas.fecha_cit,103)=convert(nvarchar,tbcitas2.fecha_cit,103) and tbcitas2.proveedor_cit=tbcitas.proveedor_cit ) as anulacion,
    (select nombre_pac from tbpacientes where codigo_pac=paciente_cit) as nombre,
    (select rtrim(ltrim(codareatel1_pac))+rtrim(ltrim(telefono1_pac)) from tbpacientes where codareatel1_pac like '04%' and codigo_pac=paciente_cit) as telefono,
    (select nombre_prv from tbproveedores where codigo_prv=proveedor_cit) as medico,
    datename(weekday,fecha_cit) dial,
    day(fecha_cit) dian,
    datename(month,fecha_cit) mes,
    year(fecha_cit) anno
    from tbcitas where 
    isnull((select codareatel1_pac+telefono1_pac from tbpacientes where codareatel1_pac like '04%' and codigo_pac=paciente_cit),'') <> ''
    and exists (select proveedor_cit from tbcitas2 where notificado_cit=0 and convert(nvarchar,tbcitas.fecha_cit,103)=convert(nvarchar,tbcitas2.fecha_cit,103) and tbcitas2.proveedor_cit=tbcitas.proveedor_cit and (tbcitas2.baremo_cit=tbcitas.baremo_cit or isnull(tbcitas2.baremo_cit,'')=''))
    ");
    
    if(mssql_num_rows($sql)>0){
    	$i=0;
    	$datasms["key"]='4eac12fbfe5c923d67f1fd904ac04d19';
    	$datasms["cli"]="J313611069";
    	$rifcli=$datasms["cli"];		
    	while($row=mssql_fetch_array($sql)){
    		$datasms["sms"][$i]["t"]=$row["telefono"];
    		$datasms["sms"][$i]["m"]=utf8_decode(utf8_encode("Presalud Info.:Sr(a) ".stripAccents(utf8_encode($row[nombre])).", El Dr(a). ".stripAccents(utf8_encode($row[medico]))." no asistira el ".stripAccents(utf8_encode($row[dial]))." ".$row[dian]." de ".$row[mes].", debera registrar otra cita, disculpe las molestias ocasionadas."));
    		$datasms["sms"][$i]["s"]="true";
    		//mssql_query("update tbcitas set sms_cit = getdate() where codigo_cit='".$row["codigo_cit"]."'");
    		mssql_query("update tbcitas2 set notificado_cit=1 where codigo_cit='".$row["anulacion"]."'");
    		$i++;
    	}
    	
    	if(count($datasms)>0){
    		$json=urlencode(base64_encode(json_encode($datasms)));
    		$ch = curl_init();
    		curl_setopt($ch,CURLOPT_URL, 'http://rtx.w3sistemas.com/sms/send/massive.php?key=4eac12fbfe5c923d67f1fd904ac04d19&cli='.$rifcli);
    		curl_setopt($ch,CURLOPT_POST, 1);
    		curl_setopt($ch,CURLOPT_USERPWD,"w3sms:sistemaoctartx");
    		curl_setopt($ch,CURLOPT_POSTFIELDS, 'data='.$json);
    		curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
    		curl_setopt($ch,CURLOPT_TIMEOUT,10000);
    		$result = curl_exec($ch);
    		curl_close($ch);
    	}
    }
    */
    $rowssqle = sqlite_array_query($dbmain, "SELECT count(*) as count FROM tbsession where user='******' and id='" . session_id() . "' limit 1", SQLITE_ASSOC);
    if ($rowssqle[0]['count'] == 0) {
        return "logout";
    } else {
        sqlite_exec($dbmain, "update tbsession set time='" . time() . "' where id='" . session_id() . "'");
        return "ok";
    }
}
示例#25
0
/**
* Web based SQLite management
* Wrapper for Default SQLite 2.x Module
* @package SQLiteManager
* @author Tanguy Pruvot
* @version $Id: sqlite2.inc.php,v 1.2 2004/12/04 18:14:49 tpruvot Exp $ $Revision: 1.2 $
*/
function sqlitem_array_query($dhb, $query, $result_type = SQLITE_BOTH, $decode_binary = TRUE)
{
    return sqlite_array_query($dhb, $query, $result_type, $decode_binary);
}
     }
     write_log(LOGFILE_CRONT_BATCH_PROCESS, basename(__FILE__) . ' line:' . __LINE__ . "[Path to the cache is not defined]");
     exit;
 }
 if (!file_exists($A2B->config["global"]['cache_path'])) {
     if ($verbose_level >= 1) {
         echo "[File doesn't exist or permission denied]\n";
     }
     write_log(LOGFILE_CRONT_BATCH_PROCESS, basename(__FILE__) . ' line:' . __LINE__ . "[File doesn't exist or permission denied]");
     exit;
 }
 // Open Sqlite
 if ($db = sqlite_open($A2B->config["global"]['cache_path'], 0666, $sqliteerror)) {
     for (;;) {
         // Select CDR
         $result = sqlite_array_query($db, "SELECT rowid , * from cc_call limit {$nb_record}", SQLITE_ASSOC);
         if (sizeof($result) > 0) {
             $column = "";
             $values = "";
             $delete_id = "( ";
             for ($i = 0; $i < sizeof($result); $i++) {
                 $j = 0;
                 if ($i == 0) {
                     $values .= "( ";
                 } else {
                     $values .= ",( ";
                 }
                 $delete_id .= $result[$i]['rowid'];
                 if (sizeof($result) > 0 && $i < sizeof($result) - 1) {
                     $delete_id .= " , ";
                 }
 public function getUserRoles($userName)
 {
     $arr = sqlite_array_query($this->link, "SELECT Role FROM Security where UserName = '******'", SQLITE_NUM);
     return $arr[0];
 }
示例#28
0
    echo "in callback, original string is {$string}\n";
    return strrev(md5($string));
}
$sql = 'SELECT md5rev(my_string) FROM mytable';
$rows = sqlite_array_query($db, $sql);
var_dump($rows);
/// aggregate
$data = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten');
sqlite_query($db, "CREATE TABLE strings(a)");
foreach ($data as $str) {
    $str = sqlite_escape_string($str);
    sqlite_query($db, "INSERT INTO strings VALUES ('{$str}')");
}
function max_len_step(&$context, $string)
{
    echo "in max_len_step: {$string}\n";
    if (strlen($string) > $context) {
        $context = strlen($string);
    }
}
function max_len_finalize(&$context)
{
    echo "in finalize, context is: {$context}\n";
    var_dump($context);
    return $context;
}
var_dump(sqlite_array_query($db, 'SELECT max_len(a) from strings'));
$r = sqlite_close($db);
?>

 function getbyid($table, $id)
 {
     // RETURNS  array of 'data1'  from a specific record identified by idx number
     $str = "SELECT idx, data1 FROM {$table} where idx = {$id}";
     $arr = sqlite_array_query($this->handle, $str, SQLITE_ASSOC);
     //one record only
     $idq['idx'] = $arr[0]['idx'];
     $arrrec = unserialize($arr[0]['data1']);
     if ($idq) {
         $reconly = array_merge($idq, $arrrec);
     } else {
         $reconly = null;
     }
     return $reconly;
 }
示例#30
0
文件: sqlite.php 项目: daolei/grw
 /**
  * 按SQL语句获取记录结果,返回数组
  * @param sql  执行的SQL语句
  */
 public function getArray($sql)
 {
     $this->arrSql[] = $sql;
     return sqlite_array_query($this->conn, $sql, SQLITE_ASSOC);
 }