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


PHP pg_num_rows函数代码示例

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


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

示例1: numRows

 /**
  * @inheritdoc
  */
 public function numRows()
 {
     if (!is_resource($this->result)) {
         return false;
     }
     return pg_num_rows($this->result);
 }
开发者ID:miknatr,项目名称:dbster,代码行数:10,代码来源:AdapterPgsqlResult.php

示例2: Migrate_20_25

/**
 * \brief 
 * delete from copyright where pfile_fk not in (select pfile_pk from pfile)
 * add foreign constraint on copyright pfile_fk if not exist
 *
 * \return 0 on success, 1 on failure
 **/
function Migrate_20_25($Verbose)
{
    global $PG_CONN;
    $sql = "select count(*) from pg_class where relname='copyright';";
    $result = pg_query($PG_CONN, $sql);
    DBCheckResult($result, $sql, __FILE__, __LINE__);
    $row = pg_fetch_assoc($result);
    pg_free_result($result);
    if (1 > $row['count']) {
        return 0;
        // fresh install, even no copyright table
    }
    $sql = "delete from copyright where pfile_fk not in (select pfile_pk from pfile);";
    $result = pg_query($PG_CONN, $sql);
    DBCheckResult($result, $sql, __FILE__, __LINE__);
    pg_free_result($result);
    /** add foreign key CONSTRAINT on pfile_fk of copyrigyt table when not exist */
    $sql = "SELECT conname from pg_constraint where conname= 'copyright_pfile_fk_fkey';";
    $conresult = pg_query($PG_CONN, $sql);
    DBCheckResult($conresult, $sql, __FILE__, __LINE__);
    if (pg_num_rows($conresult) == 0) {
        $sql = "ALTER TABLE copyright ADD CONSTRAINT copyright_pfile_fk_fkey FOREIGN KEY (pfile_fk) REFERENCES pfile (pfile_pk) ON DELETE CASCADE; ";
        $result = pg_query($PG_CONN, $sql);
        DBCheckResult($result, $sql, __FILE__, __LINE__);
        pg_free_result($result);
        print "add contr\n";
    }
    pg_free_result($conresult);
    return 0;
}
开发者ID:DanielDobre,项目名称:fossology,代码行数:37,代码来源:dbmigrate_2.0-2.5-pre.php

示例3: castResult

 public static function castResult($result, array $a, Stub $stub, $isNested)
 {
     $a['num rows'] = pg_num_rows($result);
     $a['status'] = pg_result_status($result);
     if (isset(self::$resultStatus[$a['status']])) {
         $a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
     }
     $a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING);
     if (-1 === $a['num rows']) {
         foreach (self::$diagCodes as $k => $v) {
             $a['error'][$k] = pg_result_error_field($result, $v);
         }
     }
     $a['affected rows'] = pg_affected_rows($result);
     $a['last OID'] = pg_last_oid($result);
     $fields = pg_num_fields($result);
     for ($i = 0; $i < $fields; ++$i) {
         $field = array('name' => pg_field_name($result, $i), 'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)), 'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)), 'nullable' => (bool) pg_field_is_null($result, $i), 'storage' => pg_field_size($result, $i) . ' bytes', 'display' => pg_field_prtlen($result, $i) . ' chars');
         if (' (OID: )' === $field['table']) {
             $field['table'] = null;
         }
         if ('-1 bytes' === $field['storage']) {
             $field['storage'] = 'variable size';
         } elseif ('1 bytes' === $field['storage']) {
             $field['storage'] = '1 byte';
         }
         if ('1 chars' === $field['display']) {
             $field['display'] = '1 char';
         }
         $a['fields'][] = new EnumStub($field);
     }
     return $a;
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:33,代码来源:PgSqlCaster.php

示例4: 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

示例5: geoJsonEncode

function geoJsonEncode($query)
{
    if (pg_num_rows($query) > 0) {
        $stationResult = "geojson_stations = { 'type': 'FeatureCollection','features': [";
        $platformResult = "geojson_platforms = { 'type': 'FeatureCollection','features': [";
        $stopResult = "geojson_stop_positions = { 'type': 'FeatureCollection','features': [";
        while ($row = pg_fetch_assoc($query)) {
            if ($row['geom'] != "") {
                $feature = "\n\t\t\t\t\t{\n\t\t\t\t\t\t'type': 'Feature',\n\t\t\t\t\t\t'properties': {\n\t\t\t\t\t\t\t'id': '" . $row['id'] . "',\n\t\t\t\t\t\t\t'type': '" . $row['type'] . "',\n\t\t\t\t\t\t\t'name': '" . $row['name'] . "'\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'geometry': " . $row['geom'] . "\n\t\t\t\t\t},";
            }
            switch ($row['type']) {
                case 'station':
                    $stationResult .= $feature;
                    break;
                case 'platform':
                    $platformResult .= $feature;
                    break;
                case 'stop':
                    $stopResult .= $feature;
                    break;
            }
        }
        $stationResult .= "]} \n";
        $platformResult .= "]} \n";
        $stopResult .= "]} \n";
        return $stationResult . $platformResult . $stopResult;
    }
}
开发者ID:vitalcrazz,项目名称:OSMPublicTransport,代码行数:28,代码来源:get_data.php

示例6: processar

 function processar($strTable, $strFields, $strWhere = '', $strOrderBy = '', $intLimit = '', $strGroupBy = '')
 {
     // número máximo de resultados exibidos por página
     $this->paginas['POR_PAGINA'] = $this->numero;
     $strQuery = 'SELECT ' . $strFields;
     if ($strTable) {
         $strQuery .= ' FROM ';
         if (is_array($strTable)) {
             foreach ($strTable as $tbl) {
                 $strQuery .= $this->tblprefix . $tbl . ' ';
             }
         } else {
             $strQuery .= $this->tblprefix . $strTable;
         }
     }
     if ($strWhere) {
         $strQuery .= ' WHERE ' . $strWhere;
     }
     if ($strGroupBy) {
         $strQuery .= ' GROUP BY ' . $strGroupBy;
     }
     if ($strOrderBy) {
         $strQuery .= ' ORDER BY ' . $strOrderBy;
     }
     if ($intLimit) {
         $strQuery .= ' LIMIT ' . $intLimit;
     }
     $query = $strQuery;
     /// RETORNA O VALOR TOTAL, SEM LIMIT
     $this->mysql['TOTAL'] = $this->mysql['LINK'] ? pg_num_rows(pg_query($query, $this->mysql['LINK'])) : pg_num_rows(pg_query($query));
     /// RETORNA A CONSULTA JÁ COM O LIMIT
     $this->mysql['QUERY'] = $query . " LIMIT " . $this->paginas['POR_PAGINA'] . " OFFSET " . ($this->paginas['PAGINA'] - 1) * $this->paginas['POR_PAGINA'];
     /// TOTAL DE PÁGINAS BASEADAS NO TOTAL DE RESULTADOS E NO MÁXIMO DE RESULTADOS POR PÁGINA
     $this->paginas['TOTAL'] = ceil($this->mysql['TOTAL'] / $this->paginas['POR_PAGINA']);
 }
开发者ID:rodrigopluz,项目名称:mvc,代码行数:35,代码来源:paginacao.class.php

示例7: sqlQuery

 function sqlQuery($query)
 {
     if (!$query) {
         return false;
     }
     if (b1n_DEBUG) {
         echo '<pre style="text-align: left">QUERY: ' . $query . '</pre>';
     }
     if (!$this->sqlIsConnected()) {
         user_error('DB NOT CONNECTED');
         return false;
     }
     $result = pg_query($this->sqlGetLink(), $query);
     if (is_bool($result)) {
         return pg_affected_rows($result);
     }
     $num = pg_num_rows($result);
     if ($num > 0) {
         for ($i = 0; $i < $num; $i++) {
             $row[$i] = pg_fetch_array($result, $i, PGSQL_ASSOC);
         }
         return $row;
     }
     return true;
 }
开发者ID:mmr,项目名称:b1n,代码行数:25,代码来源:sqllink.lib.php

示例8: archive

function archive($_GET)
{
    extract($_GET);
    $id += 0;
    db_conn('crm');
    $Sl = "SELECT * FROM crms WHERE userid='" . USER_ID . "'";
    $Ri = db_exec($Sl) or errDie("Unable to get data from system.");
    if (pg_num_rows($Ri) < 1) {
        return "Invalid.";
    }
    $crmdata = pg_fetch_array($Ri);
    $teams = explode("|", $crmdata['teams']);
    $Sl = "SELECT * FROM tokens WHERE id='{$id}'";
    $Ri = db_exec($Sl) or errDie("Unable to get query.");
    if (pg_num_rows($Ri) < 1) {
        return "Invalid query.";
    }
    $tokendata = pg_fetch_array($Ri);
    if (!in_array($tokendata['teamid'], $teams)) {
        return "Declined.";
    }
    $Sl = "SELECT * FROM token_actions WHERE token='{$id}'";
    $Ri = db_exec($Sl) or errDie("Unable to get actions from db.");
    while ($data = pg_fetch_array($Ri)) {
        $Sl = "INSERT INTO archived_actions (token,action,donedate,donetime,doneby,donebyid)\r\n\t\tVALUES ('{$id}','{$data['action']}','{$data['donedate']}','{$data['donetime']}','{$data['doneby']}','{$data['donebyid']}')";
        $Ro = db_exec($Sl) or errDie("Unable to archive action.");
    }
    $Sl = "DELETE FROM token_actions WHERE token='{$id}'";
    $Rl = db_exec($Sl) or errDie("Unable to delete actions.");
    $OUTPUT = "<script> window.opener.parent.mainframe.location.reload(); window.close(); </script>";
    return $OUTPUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:32,代码来源:tokens-action-archive.php

示例9: count

 public function count()
 {
     if ($this->_collection) {
         return pg_num_rows($this->_collection);
     }
     return null;
 }
开发者ID:netcon-source,项目名称:osmbuildings,代码行数:7,代码来源:Mapnik.php

示例10: scan

function scan()
{
    $invoice = array("invoice" => "Scan Invoice");
    $barcode = flashRed($invoice);
    $barcode = $barcode["invoice"];
    $sorder_num = decrypt_barcode($barcode);
    if (empty($sorder_num) || !is_numeric($sorder_num)) {
        $sorder_num = 0;
    }
    $prd_union = array();
    for ($i = 1; $i <= 14; $i++) {
        $prd_union[] = "SELECT pslip_sordid FROM \"{$i}\".pinvoices WHERE pslip_sordid='{$sorder_num}'";
    }
    $pinvoices_sql = implode(" UNION ", $prd_union);
    $sql = "SELECT pslip_sordid FROM cubit.invoices WHERE pslip_sordid='{$sorder_num}' UNION {$pinvoices_sql}";
    $invoice_rslt = db_exec($sql) or errDie("Unable to check sales order id.");
    if (!pg_num_rows($invoice_rslt) || $sorder_num == 0) {
        return scan_error("Scanned invoice does not exist.");
    }
    $sql = "SELECT sordid FROM cubit.pslip_signed_index WHERE sordid='{$sorder_num}'";
    $psi_rslt = db_exec($sql) or errDie("Unable to retrieve index.");
    if (pg_num_rows($psi_rslt) > 0) {
        scan_error("Signed invoice already uploaded");
    }
    return enter($sorder_num);
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:26,代码来源:signed_invoices.php

示例11: __construct

 /**
  * @param   resource    from pg_query() or pg_get_result()
  * @param   string      SQL used to create this result
  * @param   resource    from pg_connect() or pg_pconnect()
  * @param   boolean|string
  * @return  void
  */
 public function __construct($result, $sql, $link, $return_objects)
 {
     // PGSQL_COMMAND_OK     <- SET client_encoding = 'utf8'
     // PGSQL_TUPLES_OK      <- SELECT table_name FROM information_schema.tables
     // PGSQL_COMMAND_OK     <- INSERT INTO pages (name) VALUES ('gone soon')
     // PGSQL_COMMAND_OK     <- DELETE FROM pages WHERE id = 2
     // PGSQL_COMMAND_OK     <- UPDATE pb_users SET company_id = 1
     // PGSQL_FATAL_ERROR    <- SELECT FROM pages
     switch (pg_result_status($result)) {
         case PGSQL_EMPTY_QUERY:
             $this->total_rows = 0;
             break;
         case PGSQL_COMMAND_OK:
             $this->total_rows = pg_affected_rows($result);
             break;
         case PGSQL_TUPLES_OK:
             $this->total_rows = pg_num_rows($result);
             break;
         case PGSQL_COPY_OUT:
         case PGSQL_COPY_IN:
             Kohana_Log::add('debug', 'PostgreSQL COPY operations not supported');
             break;
         case PGSQL_BAD_RESPONSE:
         case PGSQL_NONFATAL_ERROR:
         case PGSQL_FATAL_ERROR:
             throw new Database_Exception(':error [ :query ]', array(':error' => pg_result_error($result), ':query' => $sql));
     }
     $this->link = $link;
     $this->result = $result;
     $this->return_objects = $return_objects;
     $this->sql = $sql;
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:39,代码来源:Database_Postgresql_Result.php

示例12: show_comments_page

function show_comments_page($dbconn, $diary_login)
{
    $nid = (int) $_GET['nid'];
    // Get Note
    $sql = "SELECT u.uid, n.* FROM " . TABLE_USERS . " AS u, " . TABLE_NOTES . " AS n WHERE u.login='" . $diary_login . "' AND n.uid=u.uid AND n.nid='" . $nid . "' LIMIT 1";
    $result = pg_query($sql) or die(pg_last_error($dbconn));
    if (pg_num_rows($result) == 0) {
        show_error_page($dbconn, $diary_login, "no such note!");
        return;
    } else {
        $datanote = pg_fetch_object($result, NULL);
        pg_free_result($result);
        $sql = "SELECT u.uid, s.format_note, s.page_comments, s.format_comment FROM " . TABLE_SETTINGS . " AS s, " . TABLE_USERS . " AS u WHERE u.login='" . $diary_login . "' AND s.uid=u.uid LIMIT 1";
        $result = pg_query($sql) or die(pg_last_error($dbconn));
        $dataformat = pg_fetch_object($result, NULL);
        // Strip link to add comment and number of comments
        $dataformat->format_note = preg_replace('/(<a.* href="{hrefcomment}")(.+)(.*>)/', '', $dataformat->format_note);
        $dataformat->format_note = preg_replace('/(.?{commentscount}.?)/', '', $dataformat->format_note);
        $note = assign_vars($dataformat->format_note, array('{subject}' => $datanote->subject, '{contents}' => $datanote->contents, '{date}' => date("d-m-Y", $datanote->timestamp), '{time}' => date("H:i:s", $datanote->timestamp)));
        $comments = get_comments($dbconn, $diary_login, $dataformat->format_comment, $nid);
        $sql = "SELECT COUNT(c.*) AS commentscount FROM " . TABLE_USERS . " AS u, " . TABLE_COMMENTS . " AS c WHERE c.nid='" . $nid . "' AND c.uid=u.uid AND u.login='" . $diary_login . "'";
        $result = pg_query($sql) or die(pg_last_error($dbconn));
        $datacount = pg_fetch_object($result, NULL);
        pg_free_result($result);
        $commentscount = (int) $datacount->commentscount;
        echo assign_vars($dataformat->page_comments, array('{login}' => $diary_login, '{note}' => $note, '{comments}' => $comments, '{commentscount}' => $commentscount, '{hrefcommentadd}' => 'http://' . $_SERVER['SERVER_NAME'] . '/' . PAGE_COMMENTS . '&nid=' . $nid . '&action=add'));
    }
}
开发者ID:BackupTheBerlios,项目名称:diarusie-svn,代码行数:28,代码来源:comments.inc.php

示例13: testUniqueCheck

 public function testUniqueCheck($username, $email)
 {
     //Get info from the array
     $final_username = $username;
     $final_email = $email;
     //Connect to the db
     $db = $this->connectProd();
     //Check for username and email address
     $query_user_check = "SELECT username FROM tb_users WHERE username = '" . $final_username . "'";
     $query_email_check = "SELECT email FROM tb_users WHERE email = '" . $final_email . "'";
     pg_send_query($db, $query_user_check) or die('Query failed: ' . pg_last_error());
     $username_check_result = pg_get_result($db);
     $username_check_result_rows = pg_num_rows($username_check_result);
     pg_close($db);
     if ($username_check_result_rows == 0) {
         //Set flag if no user found
         $user_check = 'pass';
     } else {
         $user_check = 'fail';
     }
     if ($email_check_result_rows == 0) {
         //Set flag if no email is found
         $email_check = 'pass';
     } else {
         $email_check = 'fail';
     }
     if ($email_check == 'pass' && $user_check == 'pass') {
         $check_result = 'pass';
         return $check_result;
     } else {
         $check_result = 'fail';
         return $check_result;
     }
 }
开发者ID:JackoThe1st,项目名称:OpenRPSDev,代码行数:34,代码来源:Db.php

示例14: comprobar_nick_modificar

function comprobar_nick_modificar(&$error, $nick, $id)
{
    $res = pg_query_params("select * from usuarios where nick = \$1 and id != \$2", array($nick, $id));
    if (pg_num_rows($res) > 0) {
        $error[] = "nick cogido. Escoja otro.";
    }
}
开发者ID:ricpelo,项目名称:juguetoon,代码行数:7,代码来源:modificar_auxiliar.php

示例15: enter_err

function enter_err($_POST, $err = "")
{
    global $_POST;
    extract($_POST);
    if (!isset($username)) {
        $username = "";
        $name = "";
        $email = "";
        $cell = "";
    }
    //
    $S1 = "SELECT * FROM usradd ORDER BY username ";
    $Ri = db_exec($S1) or errDie("Unable to get data.");
    if (pg_num_rows($Ri) < 1) {
        return "no user selected.";
    }
    // Set up table to display in
    //$cons="<table>";
    $cons = "\r\n\t\t<h3>User Details</h3>\r\n\t\t<td align=center>\r\n\t\t<table border=1 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "' width=300 class='bg-odd' >\r\n\t\t<tr><th>Name</th><th colspan=2>Options</th></tr>";
    while ($data = pg_fetch_array($Ri)) {
        $cons .= "<tr><td class='bg-odd'>{$data['username']}</td><td><a\r\n\t\t href='usredit.php?id={$data['id']}'>Edit</a></td><td><a \r\n\t         href='usrem.php?id={$data['id']}'>Remove</td></tr>";
    }
    $Cons = "<select size=1 name=Con>\r\n        <option value='No'>No</option>\r\n        <option selected value='Yes'>Yes</option>\r\n        </select>";
    $Grps = "<select size=1 name=Con>\r\n        <option value='Grp1'>Group test</option>\r\n        <option selected value='Grp2'>Gruop test2</option>\r\n        </select>";
    $get_data = "\r\n\t <h3>New User Details</h3>\r\n\t <table cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\r\n\t <form action='" . SELF . "' method='post'>\r\n\t <tr><td>{$err}<br></td></tr>\r\n\t <input type=hidden name=key value='confirm'>\r\n\t <tr class='bg-odd'><td>Username</td><td><input type=text size=20 name=username value='{$username}'> must not contain spaces</td></tr>\r\n\t <tr class='bg-even'><td>Password</td><td><input type=password size=20 name=password></td></tr>\r\n         <tr class='bg-odd'><td>Confirm password</td><td><input type=password size=20 name=password2></td></tr>\r\n\t <tr class='bg-even'><td>Name</td><td><input type=text size=20 name=name value='{$name}'></td></tr>\r\n\t <tr class='bg-odd'><td>Email</td><td><input type=text size=20 name=email value='{$email}'></td></tr>\r\n\t <tr class='bg-even'><td>Cellphone</td><td><input type=text size=20 name=cell value='{$cell}'></td></tr>\r\n\t <tr class='bg-odd'><td>Additional</td><td>Email Notification<input type=checkbox name=notify></td></tr>\r\n\t <tr class='bg-even'><td>Private</td><td align=center>{$Cons}</td></tr>\r\n\t <tr class='bg-odd'><td>Initial Group</td><td align=center>{$Grps}</td></tr>\r\n\t<tr><td colspan=2 align=right><input type=submit value='Confirm &raquo;'></td></tr>\r\n\t</form>\r\n\t</table>{$cons}";
    return $get_data;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:27,代码来源:usradd.php


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