当前位置: 首页>>代码示例>>PHP>>正文


PHP pg_prepare函数代码示例

本文整理汇总了PHP中pg_prepare函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_prepare函数的具体用法?PHP pg_prepare怎么用?PHP pg_prepare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pg_prepare函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: removeLikeToTable

function removeLikeToTable($dbconn, $userId, $msgId)
{
    pg_prepare($dbconn, "deleteLikes", "DELETE FROM yakLikes WHERE userID = \$1 AND msgID = \$2");
    $sql = pg_execute($dbconn, "deleteLikes", array($userId, $msgId));
    pg_prepare($dbconn, "updateLikes", "UPDATE yak SET likes=(likes-1) WHERE id = \$1");
    $sql = pg_execute($dbconn, "updateLikes", array($msgId));
}
开发者ID:Cutch,项目名称:CloneofYikYak,代码行数:7,代码来源:api.php

示例2: execQry

 public function execQry()
 {
     $recordString = false;
     switch ($this->connectorStructure['dbType']) {
         case "ORA":
             $connectorString = '(DESCRIPTION = (CONNECT_TIMEOUT=5) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =' . $this->connectorStructure['dbIP'] . ')(PORT = ' . $this->connectorStructure['dbPort'] . ')))(CONNECT_DATA=(SID= ' . $this->connectorStructure['dbName'] . ')))';
             $dbConnector = oci_connect($this->connectorStructure['dbUser'], $this->connectorStructure['dbPassword'], $connectorString);
             if (!$dbConnector) {
                 echo 'Failed connection.......';
             } else {
                 $oraQuery = oci_parse($dbConnector, $this->queryStructure['dbQuery']);
             }
             oci_execute($oraQuery);
             $rowsnum = oci_fetch_all($oraQuery, $recordString);
             if ($rowsnum == 0) {
                 $recordString = array();
             } else {
                 if (!(substr($this->queryStructure['dbQuery'], 1, 6) == 'select')) {
                     $oraQuery = oci_parse($dbConnector, 'commit');
                     oci_execute($oraQuery);
                     $rowsnum = oci_fetch_all($oraQuery, $recordString);
                 }
             }
             oci_close($dbConnector);
             break;
         case "PGS":
             $connectorString = "host=" . $this->connectorStructure['dbIP'] . " port=" . $this->connectorStructure['dbPort'] . " dbname=" . $this->connectorStructure['dbName'] . " user=" . $this->connectorStructure['dbUser'] . " password=" . $this->connectorStructure['dbPassword'];
             $dbConnector = pg_connect($connectorString);
             if (!$dbConnector) {
                 echo 'Failed connection.......';
             } else {
                 pg_prepare($dbConnector, $this->queryStructure['qryName'], $this->queryStructure['dbQuery']);
             }
             $queryResult = pg_execute($dbConnector, $this->queryStructure['qryName'], $this->queryStructure['qryParameters']);
             if (!$queryResult) {
                 $recordString = array();
             } else {
                 $recordString = pg_fetch_all($queryResult);
                 if (!(substr($this->queryStructure['dbQuery'], 1, 6) == 'select')) {
                     pg_prepare($dbConnector, 'commit', 'commit');
                     pg_exec($dbConnector, 'commit');
                 }
             }
             pg_close($dbConnector);
             break;
         default:
             $recordString = false;
             break;
     }
     return $recordString;
 }
开发者ID:lfcruz,项目名称:Personal,代码行数:51,代码来源:dbClass.php

示例3: populate_prepare_queries

function populate_prepare_queries($dbconn)
{
    // INSERT IN COMMANDES
    pg_prepare($dbconn, "insert_commandes", 'INSERT INTO commandes (per_id,com_date,com_date_expedition,com_date_facturation,com_statut,com_statut_facturation)' . ' VALUES ($1,$2,$3,$4,$5,$6) RETURNING com_id');
    // INSERT IN LIGNES_COMMANDE
    pg_prepare($dbconn, "insert_lignes_commande", 'INSERT INTO lignes_commande (lic_quantite,pro_id,com_id,lic_est_reduction,lic_prix_unitaire)' . ' VALUES ($1,$2,$3,$4,$5) RETURNING lic_id');
}
开发者ID:regilero,项目名称:PostgreSQL-formation-pratique,代码行数:7,代码来源:populate_app.php

示例4: create_global_tag_count_box_for_a_question

/** Luo HTML sivustolaajuinen tagilistam\"{a}\"{a}r\"{a}t kysymykselle
 * @param $question_id integer
 */
function create_global_tag_count_box_for_a_question($question_id)
{
    /* $result resource
     * $tags_array_summary array
     * $figure array
     */
    $tags_array_summary = get_tags_for_a_question($question_id);
    $dbconn = pg_connect("host=localhost port=5432 dbname=noaa user=noaa password=123");
    // to get the amout of tags Globally
    $result = pg_prepare($dbconn, "query_tag_amount", 'SELECT count(tag)
        FROM tags 
        WHERE tag = $1');
    echo "<div class='tags_summary'>";
    echo "<p>tagged</p>";
    for ($i = 0; $i < count($tags_array_summary); $i++) {
        echo "<div id='one_tag_line'>";
        $result = pg_execute($dbconn, "query_tag_amount", array($tags_array_summary[$i]['tag']));
        $figure = pg_fetch_all($result);
        for ($j = 0; $j < count($figure); $j++) {
            create_tags($tags_array_summary[$i]);
            echo "<span id='multiplier'> × " . $figure[$j]['count'] . "</span>";
        }
        echo "</div>";
    }
    echo "</div>";
}
开发者ID:vilsu,项目名称:codes,代码行数:29,代码来源:thread_functions.php

示例5: lookup_user

function lookup_user($usr_id, $cur_time)
{
    // check if user exists (if not, create user)
    // check if url exists (if not, create url)
    // add vote
    if ($con = connect_db('../auth.txt')) {
        $result = pg_prepare($con, "check_user", 'SELECT * FROM users where id = $1');
        $result = pg_execute($con, "check_user", array($usr_id));
        $usr_entry = pg_fetch_array($result);
        pg_free_result($result);
        if (!$usr_entry) {
            $result = pg_prepare($con, "reg_user", 'INSERT INTO users VALUES ($1, $2, $3)');
            $result = pg_execute($con, "reg_user", array($usr_id, 0, (int) $cur_time));
            pg_free_result($result);
            $id = $usr_id;
            $spent = 0;
            $reg = $cur_time;
        } else {
            $id = $usr_entry[0];
            $spent = $usr_entry[1];
            $reg = $usr_entry[2];
        }
        echo json_encode(array("usr" => $id, "spent" => $spent, "reg" => $reg));
    } else {
        echo json_encode(array("fuck" => "nuts"));
    }
}
开发者ID:koad,项目名称:bitvote.github.io,代码行数:27,代码来源:lookup_user.php

示例6: printUserLog

function printUserLog()
{
    //db connection
    $conn = pg_connect(HOST . " " . DBNAME . " " . USERNAME . " " . PASSWORD) or die('Could not connect: ' . pg_last_error());
    //query the database
    $result = pg_prepare($conn, "getLog", "SELECT * FROM lab8.log\n\t\t\tWHERE username LIKE \$1") or die("getLog prepare fail: " . pg_last_error());
    $result = pg_execute($conn, "getLog", array($_SESSION['user'])) or die("getLog execute fail: " . pg_last_error());
    //Printing results in HTML
    echo "<br>There where <em>" . pg_num_rows($result) . "</em> rows returned<br><br>\n";
    echo "<table class='tablestuff' border='1'>";
    //account for added form row
    echo "<tr>";
    //checking the number of fields return to populate header
    $numFields = pg_num_fields($result);
    //populating the header
    for ($i = 0; $i < $numFields; $i++) {
        $fieldName = pg_field_name($result, $i);
        echo "<th width=\"135\">" . $fieldName . "</th>\n";
    }
    echo "</tr>";
    //populating table with the results
    while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
        echo "\t<tr>\n";
        foreach ($line as $col_value) {
            echo "\t\t<td>{$col_value}</td>\n";
        }
        echo "\t</tr>\n";
    }
    echo "</table>\n";
    // Free resultset
    pg_free_result($result);
    //close connection
    pg_close($conn);
}
开发者ID:samkreter,项目名称:PHP-Postgresql-work,代码行数:34,代码来源:helperFunctions.php

示例7: prepare

 /**
  * Prepares a query.
  *
  * @param $name The name of the statement.
  * @param $sql The SQL in the statement.
  *
  * @return Whether the statement preparation was successful.
  */
 public function prepare($name, $sql)
 {
     $result = pg_prepare($this->connection, $name, $sql);
     $this->setError($result);
     $this->checkDie($result);
     return $result ? TRUE : FALSE;
 }
开发者ID:JPisaBrony,项目名称:SonicFlow,代码行数:15,代码来源:database.class.php

示例8: query

 /**
  * Execute a query and return the result
  *
  * Executes a query with optional parameters (which are automatically
  * escaped). If a name is provided, then the query will be prepared
  * and saved if necessary (or simply executed if it was already
  * prepared). Unnamed queries are prepared and executed each time they
  * are called. Note that the second and later times a named statement
  * is called, the query string is disregarded (as the statement is
  * already prepared). There is no way to reallocate a name for a
  * query.
  *
  * @param string $str The query string to execute
  * @param array $params The query parameters
  * @param string $name The name of the query
  * @throws DatabaseException
  * @return resource
  */
 public static function query($str, $params = array(), $name = null)
 {
     $p =& static::$prepared;
     if ($name && !array_key_exists($name, $p) || !$name) {
         if ($name) {
             $p[$name] = true;
         } else {
             $name = '';
         }
         error_log("Preparing query ({$name}): {$str}");
         $prepped = pg_prepare(Database::connect(), $name, $str);
         if ($prepped === false) {
             $pgerr = pg_last_error();
             if ($name) {
                 $msg = "Could not prepare query {$name}: {$pgerr}";
             } else {
                 $msg = "Could not prepare query: {$pgerr}";
             }
             throw new DatabaseException($msg);
         }
     }
     error_log("Executing query {$name}");
     $resource = pg_execute(Database::connect(), $name, $params);
     if ($resource === false) {
         $pgerr = pg_last_error();
         if ($name) {
             $msg = "Could not execute query {$name}: {$pgerr}";
         } else {
             $msg = "Could not execute query: {$pgerr}";
         }
         throw new DatabaseException($msg);
     }
     return $resource;
 }
开发者ID:rintaun,项目名称:PGModel,代码行数:52,代码来源:Database.php

示例9: execStatement

 /**
  * prepare query
  * */
 public function execStatement($sql, $params)
 {
     $this->connect();
     $result = pg_prepare($this->connection, 'myStmt', $sql);
     pg_execute($this->connection, 'myStmt', $params);
     $this->disconnect();
     return $result;
 }
开发者ID:Tookuk,项目名称:aspid,代码行数:11,代码来源:CoreDAO.php

示例10: inside_allowed_area_check

function inside_allowed_area_check($wkt)
{
    pg_prepare("", "SELECT ST_Within(ST_GeometryFromText(\$1, 25833), klarschiff.klarschiff_stadtgrenze_hro.the_geom) FROM klarschiff.klarschiff_stadtgrenze_hro");
    $result = pg_execute("", array($wkt));
    if ($row = pg_fetch_assoc($result)) {
        return $row['st_within'] === 't';
    }
    return false;
}
开发者ID:bfpi,项目名称:klarschiff-frontend-mit-mapbender,代码行数:9,代码来源:point_check.php

示例11: executeQuery

 /**
  * @param $sql
  */
 protected function executeQuery($sql)
 {
     $id = 9;
     $name = "BMW";
     $price = 36000;
     $sql = "INSERT INTO cars VALUES(\$1, \$2, \$3)";
     pg_prepare($this->connection, "prepare1", $sql) or die("Cannot prepare statement\n");
     pg_execute($this->connection, "prepare1", array($id, $name, $price)) or die("Cannot execute statement\n");
 }
开发者ID:sitthykun,项目名称:tinynamespace,代码行数:12,代码来源:Model.php

示例12: getState

 function getState($state)
 {
     $ret = array();
     $rs = pg_prepare($this->dbconn, "STATESELECT", sprintf("select *,\n    ST_x(s.geom) as x, ST_y(s.geom) as y, valid at time zone '%s' as lvalid,\n    max_gust_ts at time zone '%s' as lmax_gust_ts,\n    max_sknt_ts at time zone '%s' as lmax_sknt_ts,\n  \t\t\tvalid at time zone 'UTC' as utc_valid,\n    s.name as sname from\n    current c2, summary_%s c, stations s WHERE\n    s.state = \$1 and (s.network ~* 'RWIS' or s.network ~* 'ASOS' or\n  \t\t\ts.network in ('KCCI','KELO','KIMT') or network = 'AWOS') \n    and c.day = 'TODAY'\n    and c2.valid > 'TODAY' and c2.iemid = c.iemid and c.iemid = s.iemid", $this->tzname, $this->tzname, $this->tzname, date("Y")));
     $rs = pg_execute($this->dbconn, "STATESELECT", array($state));
     for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) {
         $ret[$row["id"]] = new IEMAccessOb($row);
     }
     return $ret;
 }
开发者ID:muthulatha,项目名称:iem,代码行数:10,代码来源:iemaccess.php

示例13: executeUpdate

 private function executeUpdate($query, $params)
 {
     $result = pg_prepare($this->connection, "query", $query);
     if ($params) {
         $resultSet = pg_execute($this->connection, "query", $params);
     } else {
         $resultSet = pg_execute($this->connection, "query");
     }
     return pg_affected_rows($resultSet);
 }
开发者ID:RMCampos,项目名称:Projerp,代码行数:10,代码来源:OperacaomodulosDAO.php

示例14: get_iemprop

function get_iemprop($propname)
{
    $dbconn = iemdb("mesosite");
    $rs = pg_prepare($dbconn, "SELECT321" . $propname, "SELECT * from properties where\n        propname = \$1");
    $rs = pg_execute($dbconn, "SELECT321" . $propname, array($propname));
    if (pg_num_rows($rs) < 1) {
        return null;
    }
    $row = pg_fetch_array($rs, 0);
    return $row["propvalue"];
}
开发者ID:muthulatha,项目名称:iem,代码行数:11,代码来源:iemprop.php

示例15: prepare

 public function prepare($query)
 {
     $id = (string) mktime();
     $res = pg_prepare($this->_connection, $id, $query);
     if ($res) {
         $rs = new pgsqlDbResultSet($res, $id, $this->_connection);
     } else {
         throw new jException('jelix~db.error.query.bad', pg_last_error($this->_connection) . '(' . $query . ')');
     }
     return $rs;
 }
开发者ID:hadrienl,项目名称:jelix,代码行数:11,代码来源:pgsql.dbconnection.php


注:本文中的pg_prepare函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。